Add aspect ratio support to the resize directive
See original GitHub issueFeature Request
I find myself wanting to resize images to multiple different sizes and formats for responsive and lazy loaded images, but always want to keep the same aspect ratio.
Ideally I could do something like this:
./assets/awesome-image.jpg?width=300;600;900&height=169;338;506
and imagetools would magically know I want that to be three 16:9 images. Not surprisingly, I actually get back 9 images with all permutations of widths and heights.
Proposed Transform
It’d be nice if we could specify either an aspect ratio and either width or height along the lines of
./assets/awesome-image.jpg?width=300;600;900&aspect=1.77777777
Existing Workaround
There is a workaround here so this is more of a convenience request than anything else. I can just split this out into three separate imports each specifying exactly one width and height.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (10 by maintainers)
Just opened a discussion for potentially adopting more ideas from services like Cloudinary!
Yep that makes total sense. It looks like the two main differences are that they have a shorthand
ar
for the aspect ratio parameter, and they value can be either a string like16:9
or a float.I should have a little time this morning, I’ll add that in and submit another PR once it’s tested