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