Skip to content

Commit

Permalink
Remove ratio check for image cropper
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelkleinert committed Nov 4, 2024
1 parent bdb97a0 commit 346a527
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions public/js/pimcore/element/tag/imagecropper.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,33 +207,16 @@ pimcore.element.tag.imagecropper = Class.create({
this.alertMessage = 'crop_error_selection_smaller_than_thumbnail'
}

// Max width and fix height for dimension
// Max width
if (sel.getWidth() >= image.getWidth()) {
sel.setStyle("width", image.getWidth() + "px");

if(this.thumbnailHeight && this.thumbnailWidth) {
sel.setStyle("height", (image.getWidth() / this.ratioX * this.ratioY) + "px");
}
}

// Max height & fix width for dimension
// Max height
if (sel.getHeight() >= image.getHeight()) {
sel.setStyle("height", image.getHeight() + "px");

if(this.thumbnailHeight && this.thumbnailWidth) {
sel.setStyle("width", (image.getHeight() / this.ratioY * this.ratioX) + "px");
}
}
} else {
// check the ratio if given
if (this.ratioX && this.ratioY) {
if (sel.getHeight() > image.getHeight()) {
sel.setStyle("height", (sel.getWidth() * (this.ratioY / this.ratioX)) + "px");
} else if (sel.getWidth() > image.getWidth()) {
sel.setStyle("width", (sel.getHeight() * (this.ratioX / this.ratioY)) + "px");
}
}

// Max width
if (sel.getWidth() > image.getWidth()) {
sel.setStyle("width", image.getWidth() + "px");
Expand Down

0 comments on commit 346a527

Please sign in to comment.