X-Git-Url: https://git.rapsys.eu/packbundle/blobdiff_plain/9dc9c9ac835f99cb2bc1cdf9940cb347a14771a8..refs/heads/master:/Util/ImageUtil.php diff --git a/Util/ImageUtil.php b/Util/ImageUtil.php index 44afe28..8a93c52 100644 --- a/Util/ImageUtil.php +++ b/Util/ImageUtil.php @@ -73,10 +73,10 @@ class ImageUtil { $a = $random % 10; //Set b - $b = $random / 10 % 10; + $b = intval($random / 10) % 10; //Set c - $c = $random / 100 % 10; + $c = intval($random / 100) % 10; //Set equation $equation = $a.' * '.$b.' + '.$c; @@ -597,9 +597,16 @@ class ImageUtil { * @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 */ - 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 @@ -624,9 +631,9 @@ class ImageUtil { //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 ]; }