From 4667d2157b72c45d8b02dd89267835a16baa9f16 Mon Sep 17 00:00:00 2001 From: fr0tt <33751346+fr0tt@users.noreply.github.com> Date: Wed, 18 Oct 2023 00:26:07 +0200 Subject: [PATCH] catch all Image Exceptions #92 --- app/Services/PostService.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Services/PostService.php b/app/Services/PostService.php index 2a8b196..47a86d6 100644 --- a/app/Services/PostService.php +++ b/app/Services/PostService.php @@ -6,8 +6,8 @@ use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Log; use Illuminate\Support\Str; +use Intervention\Image\Exception\ImageException; use Intervention\Image\Facades\Image; -use Intervention\Image\Exception\RuntimeException; use Illuminate\Support\Facades\Storage; use HeadlessChromium\BrowserFactory; @@ -243,7 +243,7 @@ public function getInfo(string $url, $act_as_bot = false) $color = $meta->getAttribute('content'); } else if ($meta->getAttribute('property') === 'og:image') { if ($meta->getAttribute('content') != '') { - $image_path = $meta->getAttribute('content'); + $image_path = $meta->getAttribute('content'); if (Str::startsWith($image_path, parse_url($image_path)['path'])) { $image_path = $this->composeImagePath($image_path, $base_url, $url); } @@ -321,10 +321,10 @@ public function saveImage($image_path, Post $post) try { $image = Image::make($image_path); - } catch (RuntimeException $e) { + } catch (ImageException $e) { Log::debug('Image could not be created'); } - if (!$image) { + if (!isset($image)) { return; }