- /**
- * Load thumbnails onto an image object.
- */
- public function loadThumbs(Image $image): void
- {
- $image->setAttribute('thumbs', [
- 'gallery' => $this->getThumbnail($image, 150, 150, false),
- 'display' => $this->getThumbnail($image, 1680, null, true),
- ]);
- }
-
- /**
- * 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.
- */
- protected function getThumbnail(Image $image, ?int $width, ?int $height, bool $keepRatio): ?string
- {
- try {
- return $this->imageService->getThumbnail($image, $width, $height, $keepRatio);
- } catch (Exception $exception) {
- return null;
- }
- }
-