]> BookStack Code Mirror - bookstack/blobdiff - app/Uploads/ImageRepo.php
Images: Extracted out image resizing to its own class
[bookstack] / app / Uploads / ImageRepo.php
index 8a770da78ab70aa13c63f017dd24ad1788431be8..4aa36bab9a21292c91b68afcd5e5fd1b28ca0426 100644 (file)
@@ -13,7 +13,8 @@ class ImageRepo
 {
     public function __construct(
         protected ImageService $imageService,
-        protected PermissionApplicator $permissions
+        protected PermissionApplicator $permissions,
+        protected ImageResizer $imageResizer,
     ) {
     }
 
@@ -225,14 +226,12 @@ class ImageRepo
     }
 
     /**
-     * Get the thumbnail for an image.
-     * If $keepRatio is true only the width will be used.
-     * Checks the cache then storage to avoid creating / accessing the filesystem on every check.
+     * Get a thumbnail URL for the given image.
      */
     protected function getThumbnail(Image $image, ?int $width, ?int $height, bool $keepRatio, bool $shouldCreate): ?string
     {
         try {
-            return $this->imageService->getThumbnail($image, $width, $height, $keepRatio, $shouldCreate);
+            return $this->imageResizer->resizeToThumbnailUrl($image, $width, $height, $keepRatio, $shouldCreate);
         } catch (Exception $exception) {
             return null;
         }