From ebb9e0c2f57938f5cc994d2bc2c453cc1398ce4e Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 28 Jun 2021 19:38:03 +0000 Subject: [PATCH] Fix resizing --- src/Module/Photo.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Module/Photo.php b/src/Module/Photo.php index 4d24c48e29..05ddd1bf50 100644 --- a/src/Module/Photo.php +++ b/src/Module/Photo.php @@ -63,6 +63,7 @@ class Photo extends BaseModule } $customsize = 0; + $square_resize = true; $photo = false; $scale = null; $stamp = microtime(true); @@ -70,6 +71,7 @@ class Photo extends BaseModule $customsize = intval($parameters['customsize']); $uid = MPhoto::stripExtension($parameters['name']); $photo = self::getAvatar($uid, $parameters['type'], $customsize); + $square_resize = !in_array($parameters['type'], ['media', 'preview']); } elseif (!empty($parameters['type'])) { $uid = MPhoto::stripExtension($parameters['name']); $photo = self::getAvatar($uid, $parameters['type'], Proxy::PIXEL_SMALL); @@ -105,10 +107,14 @@ class Photo extends BaseModule } // if customsize is set and image is not a gif, resize it - if ($photo['type'] !== "image/gif" && $customsize > 0 && $customsize < 501) { + if ($photo['type'] !== "image/gif" && $customsize > 0 && $customsize <= Proxy::PIXEL_THUMB && $square_resize) { $img = new Image($imgdata, $photo['type']); $img->scaleToSquare($customsize); $imgdata = $img->asString(); + } elseif ($photo['type'] !== "image/gif" && $customsize > 0) { + $img = new Image($imgdata, $photo['type']); + $img->scaleDown($customsize); + $imgdata = $img->asString(); } if (function_exists("header_remove")) {