From f926d549bfc6f584fe27f909702d62788b919e4d Mon Sep 17 00:00:00 2001 From: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> Date: Thu, 11 May 2023 20:03:59 +0200 Subject: [PATCH] The code has been changed for clarity https://github.com/nextcloud/server/pull/38032#discussion_r1191438624 Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> --- lib/private/Preview/Imaginary.php | 45 +++++++++---------------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/lib/private/Preview/Imaginary.php b/lib/private/Preview/Imaginary.php index da4a2d64cdf6f..b20a2b7a66de8 100644 --- a/lib/private/Preview/Imaginary.php +++ b/lib/private/Preview/Imaginary.php @@ -84,28 +84,15 @@ public function getCroppedThumbnail(File $file, int $maxX, int $maxY, bool $crop $convert = false; $autorotate = true; - $preview_format = $this->config->getSystemValueString('preview_format', 'jpeg'); switch ($file->getMimeType()) { case 'image/heic': // Autorotate seems to be broken for Heic so disable for that $autorotate = false; - switch ($preview_format) { - case 'webp': - $mimeType = 'webp'; - break; - default: - $mimeType = 'jpeg'; - } + $mimeType = 'jpeg'; break; case 'image/gif': case 'image/png': - switch ($preview_format) { - case 'webp': - $mimeType = 'webp'; - break; - default: - $mimeType = 'png'; - } + $mimeType = 'png'; break; case 'image/svg+xml': case 'application/pdf': @@ -113,25 +100,19 @@ public function getCroppedThumbnail(File $file, int $maxX, int $maxY, bool $crop $convert = true; // Converted files do not need to be autorotated $autorotate = false; - switch ($preview_format) { - case 'webp': - $mimeType = 'webp'; - break; - default: - $mimeType = 'png'; - } + $mimeType = 'png'; + break; + default: + $mimeType = 'jpeg'; + } + + $preview_format = $this->config->getSystemValueString('preview_format', 'jpeg'); + + switch ($preview_format) { // Change the format to the correct one + case 'webp': + $mimeType = 'webp'; break; default: - switch ($preview_format) { - case 'jpeg': - $mimeType = 'jpeg'; - break; - case 'webp': - $mimeType = 'webp'; - break; - default: - $mimeType = 'jpeg'; - } } $operations = [];