You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I find myself in a situation where I have both landscape and portrait images (loaded via import.meta.glob), and I want to resize them so that their larger side do not exceed 1000px, and also ensure a 16/9 aspect ratio in their respective orientation.
Currently, this is not possible to do, as we only have w and h directives, and aspect-ratio is independent from orientation.
I can see two solutions for this:
minSide, maxSide and orientedAspect
In a similar idea to vmin / vmax css units, corresponding to the smaller / larger size between vh and vw, we could have here two new directives: minSide and maxSide, allowing to set the size of the smaller / larger side of the image.
We would in addition have a new orientedAspect, that would perform the aspect ratio taking into consideration the image orientation.
Instead of introducing a new directive for each directive that is sensitive to image orientation, we could instead just introduce a single one, specifying how to apply these transforms based on the image orientation.
So when the orientationAware directive is specified, the image is always handled as if in landscape mode:
I find myself in a situation where I have both landscape and portrait images (loaded via
import.meta.glob
), and I want to resize them so that their larger side do not exceed 1000px, and also ensure a 16/9 aspect ratio in their respective orientation.Currently, this is not possible to do, as we only have
w
andh
directives, and aspect-ratio is independent from orientation.I can see two solutions for this:
minSide
,maxSide
andorientedAspect
In a similar idea to
vmin
/vmax
css units, corresponding to the smaller / larger size betweenvh
andvw
, we could have here two new directives:minSide
andmaxSide
, allowing to set the size of the smaller / larger side of the image.We would in addition have a new
orientedAspect
, that would perform the aspect ratio taking into consideration the image orientation.It would be used like the following:
These names can be bikeshedded if needed.
orientationAware
Instead of introducing a new directive for each directive that is sensitive to image orientation, we could instead just introduce a single one, specifying how to apply these transforms based on the image orientation.
So when the
orientationAware
directive is specified, the image is always handled as if in landscape mode:w
resizes the larger sideh
resizes the smaller sideaspect
is in the formatlarge:small
It would be used like the following:
Likewise, the directive name can probably be changed to something more desirable.
Do you have an opinion about the preferred approach?
The text was updated successfully, but these errors were encountered: