[Embed] Only resize thumbnail if it's bigger than the desired size

This commit is contained in:
Miguel Dantas 2019-08-19 01:41:19 +01:00 committed by Diogo Cordeiro
parent c981afcf31
commit b38e71e544

View File

@ -576,10 +576,10 @@ class EmbedPlugin extends Plugin
} }
// If the image is not of the desired size, resize it // If the image is not of the desired size, resize it
if ($info[0] !== $this->thumbnail_width || $info[1] !== $this->thumbnail_height) { if ($info[0] > $this->thumbnail_width || $info[1] > $this->thumbnail_height) {
// Temporary object, not stored in DB // Temporary object, not stored in DB
$img = new ImageFile(-1, $fullpath); $img = new ImageFile(-1, $fullpath);
$box = $img->scaleToFit($width, $height, $this->thumbnail_crop); $box = $img->scaleToFit($this->thumbnail_width, $this->thumbnail_height, $this->thumbnail_crop);
$outpath = $img->resizeTo($fullpath, $box); $outpath = $img->resizeTo($fullpath, $box);
$filename = basename($outpath); $filename = basename($outpath);
if ($fullpath !== $outpath) { if ($fullpath !== $outpath) {