diff --git a/composer.json b/composer.json index 3b9cdfeb..7821d108 100644 --- a/composer.json +++ b/composer.json @@ -17,9 +17,10 @@ "require": { "php": "^8.1|^8.2", "ext-json": "*", - "laravel/framework": "^10.0", + "intervention/image": "^2.5", + "intervention/imagecache": "^2.5", "joypixels/emoji-toolkit": "^6.0", - "intervention/image": "^2.5" + "laravel/framework": "^10.0" }, "require-dev": { "phpunit/phpunit": "^10.0", diff --git a/src/Services/ImageRenderService.php b/src/Services/ImageRenderService.php index c2552500..fc2312b2 100644 --- a/src/Services/ImageRenderService.php +++ b/src/Services/ImageRenderService.php @@ -282,8 +282,6 @@ private function renderDefaultImage(?string $alias = null): BinaryFileResponse } /** - * @todo Add cache back in - * * @param string $file * @param string $size * @return BinaryFileResponse|Response @@ -303,15 +301,11 @@ private function renderImageSize(string $file, string $size) ? $width = null : $height = null; -// $resize = $this->imageManager->cache(function ($image) use ($file, $width, $height) { -// return $image->make($file)->resize($width, $height, function ($constraint) { -// $constraint->aspectRatio(); -// }); -// }, 120); - - $resize = $this->imageManager->make($file)->resize($width, $height, function ($constraint) { - $constraint->aspectRatio(); - }); + $resize = $this->imageManager->cache(function ($image) use ($file, $width, $height) { + return $image->make($file)->resize($width, $height, function ($constraint) { + $constraint->aspectRatio(); + }); + }, 120); return $this->imageManager->make($resize)->response(); } catch (Exception $e) {