Skip to content

Feature request: image-size function #1378

@tobiastom

Description

@tobiastom

After 1.4 gave us the great data-uri, I'd like to see another function in this area: image-size( url, [type]).

The function searches for the image file at url and reads its dimensions.

The (optional) type parameter specifies the return value. Three values should be supported:

  • width – Returns the width of the image, including the px unit
  • height – Returns the height of the image, including the px unit
  • size – Returns the height of the image, including the px unit (default)

With this I could specify the following code easily:

.logo {
    background: url( 'logo.png' ) no-repeat top left;
    background-size: image-size( 'logo.png' );

    @media ONLY min-device-pixel-ratio: 1.5 {
        background-image: url( 'logo@2x.png' );
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions