diff --git a/src/Http/Controllers/CP/Assets/ThumbnailController.php b/src/Http/Controllers/CP/Assets/ThumbnailController.php index d69c4e0aba..8c0e1c2c94 100644 --- a/src/Http/Controllers/CP/Assets/ThumbnailController.php +++ b/src/Http/Controllers/CP/Assets/ThumbnailController.php @@ -3,7 +3,9 @@ namespace Statamic\Http\Controllers\CP\Assets; use Illuminate\Support\Facades\Cache; +use League\Flysystem\UnableToReadFile; use League\Glide\Server; +use Statamic\Exceptions\NotFoundHttpException; use Statamic\Facades\Asset; use Statamic\Facades\Config; use Statamic\Facades\Image; @@ -110,6 +112,8 @@ private function generate() $this->asset, $preset ? ['p' => $preset] : [] ); + } catch (UnableToReadFile $e) { + throw new NotFoundHttpException; } finally { Cache::forget($this->mutex()); } diff --git a/src/Imaging/ImageGenerator.php b/src/Imaging/ImageGenerator.php index 0970e14043..bd38934577 100644 --- a/src/Imaging/ImageGenerator.php +++ b/src/Imaging/ImageGenerator.php @@ -11,7 +11,6 @@ use League\Glide\Server; use Statamic\Contracts\Assets\Asset; use Statamic\Events\GlideImageGenerated; -use Statamic\Exceptions\NotFoundHttpException; use Statamic\Facades\Asset as Assets; use Statamic\Facades\Config; use Statamic\Facades\File; @@ -258,7 +257,7 @@ private function generate($image) try { $path = $this->server->makeImage($image, $this->params); } catch (GlideFileNotFoundException $e) { - throw new NotFoundHttpException; + throw UnableToReadFile::fromLocation($image); } GlideImageGenerated::dispatch($path, $this->params);