]> Raphaël G. Git Repositories - packbundle/commitdiff
Add format optional parameter
authorRaphaël Gertz <git@rapsys.eu>
Mon, 13 Oct 2025 13:25:29 +0000 (15:25 +0200)
committerRaphaël Gertz <git@rapsys.eu>
Mon, 13 Oct 2025 13:25:29 +0000 (15:25 +0200)
Util/ImageUtil.php

index 44afe28bb7234221c685061b8c4c54d44d287024..a556dd86cf65ca526004abdfeb91faf2d379bfa6 100644 (file)
@@ -597,9 +597,16 @@ class ImageUtil {
         * @param string $path The path
         * @param ?int $height The height
         * @param ?int $width The width
         * @param string $path The path
         * @param ?int $height The height
         * @param ?int $width The width
+        * @param ?string $format The format
         * @return array The thumb data
         */
         * @return array The thumb data
         */
-       public function getThumb(string $path, ?int $height = null, ?int $width = null): array {
+       public function getThumb(string $path, ?int $height = null, ?int $width = null, ?string $format = null): array {
+               //Without format
+               if ($format === null || !in_array($format, $this->config['formats'])) {
+                       //Set format from config
+                       $format = $this->config['thumb']['format'];
+               }
+
                //Without height
                if ($height === null) {
                        //Set height from config
                //Without height
                if ($height === null) {
                        //Set height from config
@@ -624,9 +631,9 @@ class ImageUtil {
 
                //Return array
                return [
 
                //Return array
                return [
-                       'src' => $this->router->generate('rapsyspack_thumb', ['hash' => $hash, 'path' => $short, 'height' => $height, 'width' => $width]),
-                       'width' => $width,
-                       'height' => $height
+                       'src' => $this->router->generate('rapsyspack_thumb', ['hash' => $hash, 'path' => $short, 'height' => $height, 'width' => $width, '_format' => $format]),
+                       'height' => $height,
+                       'width' => $width
                ];
        }
 
                ];
        }