Skip to content

Commit 9de24c2

Browse files
Sherwin Hluqven
Sherwin H
authored andcommitted
fix!: deprecate resizing the height param when maintaining aspect ratio
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
1 parent e28b1b4 commit 9de24c2

File tree

2 files changed

+0
-21
lines changed

2 files changed

+0
-21
lines changed

spec/ImgixTagSpec.js

-15
Original file line numberDiff line numberDiff line change
@@ -451,21 +451,6 @@ describe('ImgixTag', function() {
451451
prev = element;
452452
}
453453
});
454-
455-
it('correctly calculates `h` to maintain aspect ratio, when specified', function() {
456-
global.mockElement['ix-src'] =
457-
'https://assets.imgix.net/presskit/imgix-presskit.pdf?page=3&w=600&h=300';
458-
var tag = new ImgixTag(global.mockElement, global.imgix.config),
459-
srcsetPairs = tag.el.srcset.split(',');
460-
461-
for (var i = 0, srcsetPair, w, h; i < srcsetPairs.length; i++) {
462-
srcsetPair = srcsetPairs[i];
463-
w = parseInt(srcsetPair.match(/w=(\d+)/)[1], 10);
464-
h = parseInt(srcsetPair.match(/h=(\d+)/)[1], 10);
465-
466-
expect(Math.round(w / 2)).toEqual(h);
467-
}
468-
});
469454
});
470455

471456
describe('#sizes', function() {

src/ImgixTag.js

-6
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,6 @@ var ImgixTag = (function () {
158158
var clonedParams = util.shallowClone(this.baseParams);
159159
clonedParams.w = targetWidth;
160160

161-
if (this.baseParams.w != null && this.baseParams.h != null) {
162-
clonedParams.h = Math.round(
163-
targetWidth * (this.baseParams.h / this.baseParams.w)
164-
);
165-
}
166-
167161
var url = this.baseUrlWithoutQuery + '?',
168162
val,
169163
params = [];

0 commit comments

Comments
 (0)