Skip to content

Commit 93c2da3

Browse files
committed
feat: add fallback image to article image on show page
1 parent b699459 commit 93c2da3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

resources/views/articles/show.blade.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,15 @@
2020

2121
<div class="container mx-auto">
2222
<div class="px-4 lg:px-0 lg:mx-48">
23-
<div
24-
class="w-full bg-center {{ $article->hasHeroImage() ? 'bg-cover' : '' }} bg-gray-800 p-6 lg:p-8"
25-
style="background-image: linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4)), url({{ $article->heroImage(2000,384) }});"
26-
>
23+
<div class="relative w-full bg-center bg-gray-800 p-6 lg:p-8 z-10">
24+
<img class="absolute w-full h-full left-0 top-0 object-cover -z-10"
25+
style="background-image: linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4))"
26+
src="{{ $article->heroImage(2000,384) }}"
27+
alt="Example image"
28+
onerror="
29+
this.onerror=null;
30+
this.src='images/default-background.svg';"
31+
>
2732
<div class="flex items-center justify-between mb-28 text-sm lg:text-base">
2833
<a href="{{ route('articles') }}" class="flex items-center text-white hover:underline">
2934
<x-heroicon-s-arrow-left class="w-4 h-4 fill-current" />

0 commit comments

Comments
 (0)