From 05519c20ba238fc09e54784ae236d3953ea83db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danyi=20D=C3=A1vid?= Date: Fri, 21 Jul 2017 21:33:42 +0200 Subject: [PATCH] * fixed image download --- config/routes.php | 2 +- src/App/Service/GalleryService.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) 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;