Skip to content

Commit

Permalink
fix!: deprecate resizing the height param when maintaining aspect ratio
Browse files Browse the repository at this point in the history
BREAKING CHANGE: 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
  • Loading branch information
Sherwin H authored and luqven committed Oct 3, 2022
1 parent e28b1b4 commit 9de24c2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 21 deletions.
15 changes: 0 additions & 15 deletions spec/ImgixTagSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,21 +451,6 @@ describe('ImgixTag', function() {
prev = element;
}
});

it('correctly calculates `h` to maintain aspect ratio, when specified', function() {
global.mockElement['ix-src'] =
'https://assets.imgix.net/presskit/imgix-presskit.pdf?page=3&w=600&h=300';
var tag = new ImgixTag(global.mockElement, global.imgix.config),
srcsetPairs = tag.el.srcset.split(',');

for (var i = 0, srcsetPair, w, h; i < srcsetPairs.length; i++) {
srcsetPair = srcsetPairs[i];
w = parseInt(srcsetPair.match(/w=(\d+)/)[1], 10);
h = parseInt(srcsetPair.match(/h=(\d+)/)[1], 10);

expect(Math.round(w / 2)).toEqual(h);
}
});
});

describe('#sizes', function() {
Expand Down
6 changes: 0 additions & 6 deletions src/ImgixTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,6 @@ var ImgixTag = (function () {
var clonedParams = util.shallowClone(this.baseParams);
clonedParams.w = targetWidth;

if (this.baseParams.w != null && this.baseParams.h != null) {
clonedParams.h = Math.round(
targetWidth * (this.baseParams.h / this.baseParams.w)
);
}

var url = this.baseUrlWithoutQuery + '?',
val,
params = [];
Expand Down

0 comments on commit 9de24c2

Please sign in to comment.