Replies: 1 comment
-
|
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Motivation
Astro's built-in image pipeline lets you specify
densitiesorwidths, for generating image source sets.densitiesgenerates a source set that browsers will use on displays with different pixel densities —it's not meant to be used for responsive images.widthsrequires the caller to already know the physical size of the image, something that's only pulled from the image later in the pipeline. Additionally, it requires the caller passes a correspondingsizesattribute separately, which might be bothersome depending on the scenario.Proposal
We'll add a new property that lets the caller pass a list of scale factors, from 0% to 100%. These factors will be used by the image service to generate both the source set and the corresponding
sizesattribute. This will let browsers pick the image with the right size for its container.Note
For each generated size
${WIDTH}x${HEIGHT}, a corresponding(width <= ${WIDTH}px): ${WIDTH}pxentry will be added tosizes.API
Properties for the built-in image service follow conventions set by the HTML standard, using plurals for
densitiesandwidths, while elsewhere in Astro the:listconvention is also used (e.g.class:list). We find the latter less ambiguous, so this is the convention used here.The new property is called
autoscale:list, since it is a list of values used to automatically scale the image.Configuration
autoscale:listwill also be added to thedefaultsproperty of the image service configuration, providing a way for the user to set a default value for all transformations where it would not conflict with other parameters or attributes (such asdensities,widthsorsizes).Beta Was this translation helpful? Give feedback.
All reactions