question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add aspect ratio support to the resize directive

See original GitHub issue

Feature 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:closed
  • Created 2 years ago
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
JonasKruckenbergcommented, Apr 26, 2021

Just opened a discussion for potentially adopting more ideas from services like Cloudinary!

2reactions
tony-sullcommented, Apr 26, 2021

I was going to propose that the API mirrored an existing popular one (like Cloudinary has).

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 like 16: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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Implement responsive aspect ratio on window resize ... - Daily.co
In this example, we add a React ref to the CallFrame component, which is where the iframe gets rendered. Next, we use a...
Read more >
How to pass aspectRatio option to alsoResize Object in ...
add ("resizable", "alsoResizeReverse", { start: function(event, ui) { var self = $(this).data("resizable"), o = self.options; var _store = ...
Read more >
Enforce a aspect ratio when resizing for Windows · Issue #8036
As in topic. API currently offers fixed ratio only for Mac but not for Windows.
Read more >
Change the aspect ratio of an image using CSS - gavsblog
In this post I'll show you how to change the aspect ratio of an image or element using CSS, and explain why this...
Read more >
Aspect Ratio - Tailwind CSS
Use the aspect-{ratio} utilities to set the desired aspect ratio of an element.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found