Skip to content

Commit

Permalink
Merge pull request #11 from thelia-modules/feature/format-in-loop
Browse files Browse the repository at this point in the history
add format param in image loop
  • Loading branch information
Lucanis authored Feb 20, 2024
2 parents d9c37bc + 9b9215c commit 4505577
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Config/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>1.2.3</version>
<version>1.2.4</version>
<authors>
<author>
<name></name>
Expand Down
4 changes: 3 additions & 1 deletion Loop/LibraryImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions Service/LibraryImageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,16 @@ public function deleteImage(
public function getImagePublicUrl(
LibraryImage $image = null,
$width = null,
$height = null
$height = null,
$format = null
) {
if (null == $image) {
return null;
}

$fileName = $this->imageService->getImageFileName($image);

$format = pathinfo($fileName, \PATHINFO_EXTENSION);
$format = $format ?? pathinfo($fileName, \PATHINFO_EXTENSION);
$size = 'max';
if ($width || $height) {
$size = $width.','.$height;
Expand Down

0 comments on commit 4505577

Please sign in to comment.