diff --git a/config/routes.php b/config/routes.php index db29a93..e38fa04 100644 --- a/config/routes.php +++ b/config/routes.php @@ -29,4 +29,4 @@ $app->get('/', App\Action\HomePageAction::class, 'home'); $app->get('/api/galleries', App\Action\ListGalleriesAction::class, 'api.galleries'); $app->get('/api/gallery/{slug}', App\Action\GetGalleryImagesAction::class, 'api.gallery'); -$app->get('/api/image/{slug}/{image}[/thumb]', App\Action\GetImageAction::class, 'api.image'); +$app->get('/api/image/{slug}/{image}[/{thumb}]', App\Action\GetImageAction::class, 'api.image'); diff --git a/src/App/Service/GalleryService.php b/src/App/Service/GalleryService.php index 3bd397f..489fef0 100644 --- a/src/App/Service/GalleryService.php +++ b/src/App/Service/GalleryService.php @@ -61,18 +61,18 @@ class GalleryService ]; } - public function getImage(string $slug, string $image, bool $size) + public function getImage(string $slug, string $image, $size = false): string { $config = $this->getConfig(); $galleryDir = sprintf(self::IMAGE_BASEDIR, $config['galleries'][$slug]['dir']); $imageFileName = $size - ? $galleryDir . $image - : $this->getResizedImageName($galleryDir, $image, $size); + ? $this->getResizedImageName($galleryDir, $image, $size) + : ( $galleryDir . $image ); return $imageFileName; } - protected function getResizedImageName($galleryDirectory, $imageName, $size) + protected function getResizedImageName($galleryDirectory, $imageName, $size): string { $numericSize = $size == 'thumb' ? self::THUMBNAIL_SIZE : $size;