From 8b106dbc6c01818fd0b40c014d9b74f9c32505a9 Mon Sep 17 00:00:00 2001 From: Miguel Dantas Date: Sat, 3 Aug 2019 21:02:21 +0100 Subject: [PATCH] [MEDIA] Fixed wrong image cropping --- lib/imagefile.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/imagefile.php b/lib/imagefile.php index 9f0d386b46..2d43761bbc 100644 --- a/lib/imagefile.php +++ b/lib/imagefile.php @@ -345,7 +345,13 @@ class ImageFile extends MediaFile $img = $img->orientate(); } - $img->crop($box['width'], $box['height'], $box['x'], $box['y']); + $img->fit($box['width'], $box['height'], + function ($constraint) { + if (common_config('attachments', 'upscale') !== true) { + $constraint->upsize(); // Prevent upscaling + } + } + ); // Ensure we save in the correct format and allow customization based on type $type = $this->preferredType(); -- 2.39.5