From fe433ae802dbe0e9be378f07668779aecde334d5 Mon Sep 17 00:00:00 2001 From: floppydiskette Date: Mon, 9 Dec 2024 20:48:27 +0000 Subject: [PATCH] Handle no image being returned by tinyfox.dev --- app/View/Components/Wah.php | 4 +++- resources/views/components/wah.blade.php | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/View/Components/Wah.php b/app/View/Components/Wah.php index 3b1d546..aeb5757 100644 --- a/app/View/Components/Wah.php +++ b/app/View/Components/Wah.php @@ -21,7 +21,9 @@ public function getWah(): string { try { $response = Http::get('https://api.tinyfox.dev/img.json?animal=wah'); $data = $response->json(); - return "https://api.tinyfox.dev".$data["loc"]; + if ($data == null) return ""; + return "https://api.tinyfox.dev" . $data["loc"]; + } catch (Exception $ex) { return ""; } diff --git a/resources/views/components/wah.blade.php b/resources/views/components/wah.blade.php index cea770e..4312606 100644 --- a/resources/views/components/wah.blade.php +++ b/resources/views/components/wah.blade.php @@ -1,5 +1,10 @@

Random Wah!

- -

Image "stolen" from tinyfox.dev

+ @if ($wah !== "") + Random image featuring a Red Panda +

Image "stolen" from tinyfox.dev

+ @else + 250x250 Placeholder Image +

Unable to retrieve image

+ @endif