Skip to content

Commit

Permalink
Added support for natural ratio crop on image set field
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyjb committed Jul 30, 2020
1 parent a4938ed commit 1580c04
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions module/image-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,13 @@ export class ImageSet {
._options
.cropAspectRatios.push(parseFloat(cropAspectRatio))
}
}

if (this._options.versions.length
!== this._options.cropAspectRatios.length) {
throw Error('Length of crop aspect ratios must match versions')
}
if (this._options.cropAspectRatios.length > 0
&& this._options.versions.length
!== this._options.cropAspectRatios.length) {

throw Error('Length of crop aspect ratios must match versions')
}

// Conver `maxPreviewSize` option given as an attribute to a list of
Expand Down Expand Up @@ -829,7 +831,7 @@ ImageSet.behaviours = {
return new ImageEditor(
inst.getAssetProp(version, 'editingURL'),
inst.baseTransforms[version],
inst.getCropAspectRatio(version),
inst.getCropAspectRatio(version) || null,
inst._options.fixCropAspectRatio,
inst._options.maxPreviewSize
)
Expand Down

0 comments on commit 1580c04

Please sign in to comment.