From d38adac6ba5c0de345cef9a049dd3ed0311749f2 Mon Sep 17 00:00:00 2001 From: Kevin Meijer Date: Thu, 12 Sep 2024 21:14:30 +0200 Subject: [PATCH] Return empty string when image is not found (#242) * Return empty string when image is not found * Fix styling --------- Co-authored-by: kevinmeijer97 --- src/Breakpoint.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Breakpoint.php b/src/Breakpoint.php index 2a10b97..963edec 100644 --- a/src/Breakpoint.php +++ b/src/Breakpoint.php @@ -10,6 +10,7 @@ use Illuminate\Support\Facades\Config; use League\Flysystem\FilesystemException; use Statamic\Contracts\Assets\Asset; +use Statamic\Exceptions\NotFoundHttpException; use Statamic\Facades\Blink; use Statamic\Facades\Glide as GlideManager; use Statamic\Imaging\ImageGenerator; @@ -265,7 +266,11 @@ private function placeholder(): string 'cache' => Config::get('statamic.assets.image_manipulation.cache', false), ]; - $manipulationPath = $imageGenerator->generateByAsset($this->asset, $params); + try { + $manipulationPath = $imageGenerator->generateByAsset($this->asset, $params); + } catch (NotFoundHttpException $e) { + return ''; + } $base64Image = $this->readImageToBase64($manipulationPath);