From 75e6ddf701067001f5a153662e5a4ee437ebedce Mon Sep 17 00:00:00 2001 From: Marco Ingraiti Date: Tue, 30 Apr 2024 15:49:36 +0200 Subject: [PATCH 1/2] Update ps_imageslider.php --- ps_imageslider.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ps_imageslider.php b/ps_imageslider.php index 0b03bfa..26562ec 100644 --- a/ps_imageslider.php +++ b/ps_imageslider.php @@ -477,9 +477,11 @@ protected function _postProcess() 'gif', 'jpeg', 'png', + 'avif', + 'webp', ] ) && - in_array($type, ['jpg', 'gif', 'jpeg', 'png']) + in_array($type, ['jpg', 'gif', 'jpeg', 'png', 'avif', 'webp']) ) { $temp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS'); $salt = sha1(microtime()); From 6484f57cebdf204d038ff31a7c035b8098102467 Mon Sep 17 00:00:00 2001 From: Marco Ingraiti Date: Thu, 2 May 2024 10:10:31 +0200 Subject: [PATCH 2/2] refactor: moved mimetypes to constant declaration --- ps_imageslider.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/ps_imageslider.php b/ps_imageslider.php index 26562ec..8dd8273 100644 --- a/ps_imageslider.php +++ b/ps_imageslider.php @@ -43,6 +43,7 @@ class Ps_ImageSlider extends Module implements WidgetInterface protected $default_pause_on_hover = 1; protected $default_wrap = 1; protected $templateFile; + const SUPPORTED_MIME_TYPES = ['jpg', 'gif', 'jpeg', 'png', 'avif', 'webp']; /** * @var string */ @@ -472,16 +473,9 @@ protected function _postProcess() !empty($imagesize) && in_array( Tools::strtolower(Tools::substr(strrchr($imagesize['mime'], '/'), 1)), - [ - 'jpg', - 'gif', - 'jpeg', - 'png', - 'avif', - 'webp', - ] + self::SUPPORTED_MIME_TYPES ) && - in_array($type, ['jpg', 'gif', 'jpeg', 'png', 'avif', 'webp']) + in_array($type, self::SUPPORTED_MIME_TYPES) ) { $temp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS'); $salt = sha1(microtime());