imgix.js icon indicating copy to clipboard operation
imgix.js copied to clipboard

chore: deprecate resizing the height param when maintaining aspect ratio

Open sherwinski opened this issue 5 years ago • 3 comments

This PR removes the logic in ix-src responsible for resizing the h (height) parameter to maintain aspect ratio when building the srcset attribute. With the help of the imgix aspect ratio parameter, users can now achieve the same effect with the inclusion of the ar parameter. This should yield slightly better performance, code cleanliness, and bring the library more in line with the imgix API. Please note, the ar parameter should also be used with fit=crop to take effect.


Demo The following is an example of how to use the ar parameter in this library. More information on usage specifics can be found on the imgix API docs.

<img
	ix-src="https://assets.imgix.net/examples/treefrog.jpg?w=1000&ar=2%3A1&fit=crop"
	sizes="100vw"
>

With the previous behavior, passing in both a w (width) and h (height) parameter would resize the height at each srcset pair to maintain the ratio between the two. The same effect can be achieved by passing the ar parameter once without the need to recalculate/resize the height. This will produce an image cropped to the specified ratio:

Example srcset URL
Before https://assets.imgix.net/examples/treefrog.jpg?w=1000&h=500&fit=crop
After https://assets.imgix.net/examples/treefrog.jpg?w=1000&ar=2%3A1&fit=crop

sherwinski avatar Oct 24 '19 20:10 sherwinski

The suspense on this one is killing me 😰

frederickfogerty avatar Oct 05 '20 10:10 frederickfogerty

The progress on this one is just b l i s t e r i n g 🚀 🐢

frederickfogerty avatar Mar 26 '21 15:03 frederickfogerty

I'm on the edge of my seat! 🏃

frederickfogerty avatar Nov 11 '21 11:11 frederickfogerty

Contributors

sherwinski

Commit-Lint commands

You can trigger Commit-Lint actions by commenting on this PR:

  • @Commit-Lint merge patch will merge dependabot PR on "patch" versions (X.X.Y - Y change)
  • @Commit-Lint merge minor will merge dependabot PR on "minor" versions (X.Y.Y - Y change)
  • @Commit-Lint merge major will merge dependabot PR on "major" versions (Y.Y.Y - Y change)
  • @Commit-Lint merge disable will desactivate merge dependabot PR
  • @Commit-Lint review will approve dependabot PR
  • @Commit-Lint stop review will stop approve dependabot PR

commit-lint[bot] avatar Sep 30 '22 18:09 commit-lint[bot]

:tada: This PR is included in version 4.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

imgix-git-robot avatar Oct 03 '22 22:10 imgix-git-robot

@frederickfogerty can finally rejoice 😌

sherwinski avatar Oct 04 '22 15:10 sherwinski

@sherwinski jumped out of my chair

frederickfogerty avatar Oct 28 '22 08:10 frederickfogerty