[ATTACHMENTS] Ensure thumbnail dimensions are bounded and change way cropping is implemented

This commit is contained in:
2021-08-18 13:08:15 +01:00
parent f67173061b
commit 6799052ff5
2 changed files with 8 additions and 5 deletions

View File

@@ -147,6 +147,8 @@ class Attachment extends Controller
throw new ClientException(_m('The requested thumbnail dimensions are not allowed'), 400); // 400 Bad Request
}
[$width, $height] = AttachmentThumbnail::predictScalingValues($attachment->getWidth(), $attachment->getHeight(), $width, $height, $crop);
$thumbnail = AttachmentThumbnail::getOrCreate(attachment: $attachment, width: $width, height: $height, crop: $crop);
$filename = $thumbnail->getFilename();