Handle no image being returned by tinyfox.dev
This commit is contained in:
parent
20c16b7908
commit
fe433ae802
2 changed files with 10 additions and 3 deletions
|
@ -21,7 +21,9 @@ public function getWah(): string {
|
||||||
try {
|
try {
|
||||||
$response = Http::get('https://api.tinyfox.dev/img.json?animal=wah');
|
$response = Http::get('https://api.tinyfox.dev/img.json?animal=wah');
|
||||||
$data = $response->json();
|
$data = $response->json();
|
||||||
return "https://api.tinyfox.dev".$data["loc"];
|
if ($data == null) return "";
|
||||||
|
return "https://api.tinyfox.dev" . $data["loc"];
|
||||||
|
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
<div class="wah">
|
<div class="wah">
|
||||||
<h3>Random Wah!</h3>
|
<h3>Random Wah!</h3>
|
||||||
<img src="{{ $wah }}">
|
@if ($wah !== "")
|
||||||
<p>Image "stolen" from <a href="https://tinyfox.dev/">tinyfox.dev</a></p>
|
<img src="{{ $wah }}" alt="Random image featuring a Red Panda">
|
||||||
|
<p>Image "stolen" from <a href="https://tinyfox.dev/">tinyfox.dev</a></p>
|
||||||
|
@else
|
||||||
|
<img src="https://placehold.co/250x250" alt="250x250 Placeholder Image">
|
||||||
|
<p>Unable to retrieve image</p>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue