From 9b9215cb8cffc3bccc398d37afa4ee73c425e701 Mon Sep 17 00:00:00 2001 From: Lucanis Date: Tue, 20 Feb 2024 11:39:31 +0100 Subject: [PATCH] add format param in image loop --- Config/module.xml | 2 +- Loop/LibraryImage.php | 4 +++- Service/LibraryImageService.php | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Config/module.xml b/Config/module.xml index dc54064..490e310 100755 --- a/Config/module.xml +++ b/Config/module.xml @@ -20,7 +20,7 @@ en_US fr_FR - 1.2.3 + 1.2.4 diff --git a/Loop/LibraryImage.php b/Loop/LibraryImage.php index a84b727..beff5a9 100755 --- a/Loop/LibraryImage.php +++ b/Loop/LibraryImage.php @@ -49,6 +49,7 @@ protected function getArgDefinitions() Argument::createBooleanTypeArgument('only_visible'), Argument::createIntTypeArgument('width'), Argument::createIntTypeArgument('height'), + Argument::createAlphaNumStringTypeArgument('format'), new Argument( 'resize_mode', new TypeCollection( @@ -113,7 +114,8 @@ public function parseResults(LoopResult $loopResult) $imageUrl = $libraryImageService->getImagePublicUrl( $image, $this->getWidth(), - $this->getHeight() + $this->getHeight(), + $this->getFormat() ); $row = new LoopResultRow($image); diff --git a/Service/LibraryImageService.php b/Service/LibraryImageService.php index a00ec8d..62daf5c 100755 --- a/Service/LibraryImageService.php +++ b/Service/LibraryImageService.php @@ -97,7 +97,8 @@ public function deleteImage( public function getImagePublicUrl( LibraryImage $image = null, $width = null, - $height = null + $height = null, + $format = null ) { if (null == $image) { return null; @@ -105,7 +106,7 @@ public function getImagePublicUrl( $fileName = $this->imageService->getImageFileName($image); - $format = pathinfo($fileName, \PATHINFO_EXTENSION); + $format = $format ?? pathinfo($fileName, \PATHINFO_EXTENSION); $size = 'max'; if ($width || $height) { $size = $width.','.$height;