From 66571f662fbdbc117c66067337da8afd3cc169ec Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sun, 22 Sep 2019 14:48:50 +0200 Subject: [PATCH] Hotfix (will be included in v2.5.0 release): Don't break image loading when php-gd extension is not installed --- changelog/52_2.5.0_2019-09-22.md | 2 +- services/FilesService.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/changelog/52_2.5.0_2019-09-22.md b/changelog/52_2.5.0_2019-09-22.md index d9346cac..ca10105b 100644 --- a/changelog/52_2.5.0_2019-09-22.md +++ b/changelog/52_2.5.0_2019-09-22.md @@ -75,7 +75,7 @@ - Fixed that date/time pickers not considered the `config.php` setting `CALENDAR_FIRST_DAY_OF_WEEK` - Improved the handling which entry page to use with disabled feature flags (thanks @nielstholenaar) - Boolean settings provided via environment variables (so the strings `true` and `false`) are now parsed correctly (thanks @mduret) -- All uploaded pictures (currently for products and recipes) are now automatically downscaled to the appropriate size when serving them to improve page load times +- All uploaded pictures (currently for products and recipes) are now automatically downscaled to the appropriate size when serving them to improve page load times (this requires the `php-gd` extension, if not installed, images will not be downscaled) - It's now possible to test plural forms of quantity units (button on the quantity unit edit page, only visible if the current language requires more than 2 plural forms) - On the login page no menus and the sidebar is now hidden - New translations: (thanks all the translators) diff --git a/services/FilesService.php b/services/FilesService.php index 47ed79a4..cd9ebd6d 100644 --- a/services/FilesService.php +++ b/services/FilesService.php @@ -42,6 +42,11 @@ class FilesService extends BaseService $fileNameDownscaled = $fileNameWithoutExtension . '__downscaledto' . ($bestFitHeight ? $bestFitHeight : 'auto') . 'x' . ($bestFitWidth ? $bestFitWidth : 'auto') . '.' . $fileExtension; $filePathDownscaled = $this->GetFilePath($group, $fileNameDownscaled); + if (!extension_loaded('gd')) + { + return $filePath; + } + try { if (!file_exists($filePathDownscaled))