Skip to content

Commit 002b161

Browse files
committed
file preview fix
1 parent 38b996e commit 002b161

File tree

7 files changed

+11
-24
lines changed

7 files changed

+11
-24
lines changed

app/helpers.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,3 @@ function route_to_reply_able(mixed $replyAble): string
9191
route('discussions.show', $replyAble->slug());
9292
}
9393
}
94-
95-
if(! function_exists('getAvatar')) {
96-
/**
97-
* @param $title
98-
* @param bool $rounded
99-
*
100-
* @return string
101-
*/
102-
function getAvatar($title,bool $rounded=false): string
103-
{
104-
return 'https://ui-avatars.com/api/?name=' . urlencode($title). '&background=random&bold=true&format=svg&size=512&rounded='.$rounded;
105-
}
106-
}

resources/views/articles/show.blade.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
<div>
7070
<h2 class="text-xs leading-5 font-medium tracking-wide uppercase text-skin-base">Article suivant</h2>
7171
<a href="{{ route('articles.show', $next) }}" class="mt-3 flex items-start space-x-2">
72-
<img class="h-8 w-8 object-cover shadow-lg rounded-md" src="{{ $next->getFirstMediaUrl('media') }}" alt="{{ $next->slug }}">
72+
<img class="h-8 w-8 object-cover shadow-lg rounded-md" src="{{ $next->getFirstMediaUrl('media') }}" alt="{{ $next->slug }}" onerror="this.onerror=null;this.src='{{ asset('images/socialcard.png') }}'">
7373
<span class="text-sm font-medium leading-4 text-skin-inverted hover:text-skin-primary-hover line-clamp-2">{{ $next->title }}</span>
7474
</a>
7575
</div>
@@ -79,7 +79,7 @@
7979
<div>
8080
<h2 class="text-xs leading-5 font-medium tracking-wide uppercase text-skin-base">Article précédent</h2>
8181
<a href="{{ route('articles.show', $previous) }}" class="mt-3 flex items-start space-x-2">
82-
<img class="h-8 w-8 object-cover shadow-lg rounded-md" src="{{ $previous->getFirstMediaUrl('media') }}" alt="{{ $previous->slug }}">
82+
<img class="h-8 w-8 object-cover shadow-lg rounded-md" src="{{ $previous->getFirstMediaUrl('media') }}" alt="{{ $previous->slug }}" onerror="this.onerror=null;this.src='{{ asset('images/socialcard.png') }}'">
8383
<span class="text-sm font-medium leading-4 text-skin-inverted hover:text-skin-primary-hover line-clamp-2">{{ $previous->title }}</span>
8484
</a>
8585
</div>
@@ -229,7 +229,7 @@ class="inline-flex items-center py-2 px-4 border border-skin-base rounded-md sha
229229
</a>
230230
@if($article->isNotApproved())
231231
@hasanyrole('admin|moderator')
232-
<button onclick="Livewire.emit('openModal', 'modals.approved-article', {{ json_encode([$article->id]) }})" type="button" class="-ml-px relative inline-flex items-center px-4 py-2 border border-skin-base bg-skin-card text-sm font-medium text-green-500 hover:bg-skin-card-muted focus:z-10 focus:outline-none focus:ring-1 focus:ring-green-500 focus:border-green-500 focus:border-green-500 focus:ring-offset-body">
232+
<button onclick="Livewire.emit('openModal', 'modals.approved-article', {{ json_encode([$article->id]) }})" type="button" class="-ml-px relative inline-flex items-center px-4 py-2 border border-skin-base bg-skin-card text-sm font-medium text-green-500 hover:bg-skin-card-muted focus:z-10 focus:outline-none focus:ring-1 focus:ring-green-500 focus:border-green-500 focus:ring-offset-body">
233233
<span class="sr-only">{{ __('Approuver') }}</span>
234234
<x-untitledui-check-verified-02 class="h-5 w-5" />
235235
</button>
@@ -251,7 +251,7 @@ class="inline-flex items-center py-2 px-4 border border-skin-base rounded-md sha
251251
<div>
252252
<h2 class="text-xs leading-5 tracking-wide uppercase text-skin-base">{{ __('Article suivant') }}</h2>
253253
<div class="mt-3 flex items-start space-x-2">
254-
<img class="h-10 w-10 object-cover shadow-lg rounded-md" src="{{ $next->getFirstMediaUrl('media') ?? asset('images/socialcard.png') }}" alt="{{ $next->slug }}" onerror="this.onerror=null;this.src='{{ getAvatar($next->title) }}'">
254+
<img class="h-10 w-10 object-cover shadow-lg rounded-md" src="{{ $next->getFirstMediaUrl('media') ?? asset('images/socialcard.png') }}" alt="{{ $next->slug }}" onerror="this.onerror=null;this.src='{{ asset('images/socialcard.png') }}'">
255255
<div class="flex flex-col space-y-1">
256256
<a class="text-base font-medium leading-4 text-skin-inverted hover:text-skin-primary-hover line-clamp-2" href="{{ route('articles.show', $next) }}">{{ $next->title }}</a>
257257
<span class="text-sm text-skin-muted">{{ __(':time min de lecture', ['time' => $next->readTime()]) }}</span>
@@ -264,7 +264,7 @@ class="inline-flex items-center py-2 px-4 border border-skin-base rounded-md sha
264264
<div>
265265
<h2 class="text-xs leading-5 tracking-wide uppercase text-skin-base">{{ __('Article précédent') }}</h2>
266266
<div class="mt-3 flex items-start space-x-2">
267-
<img class="h-10 w-10 object-cover shadow-lg rounded-md" src="{{ $previous->getFirstMediaUrl('media') ?? asset('images/socialcard.png') }}" alt="{{ $previous->slug }}" onerror="this.onerror=null;this.src='{{ getAvatar($previous->title) }}'">
267+
<img class="h-10 w-10 object-cover shadow-lg rounded-md" src="{{ $previous->getFirstMediaUrl('media') ?? asset('images/socialcard.png') }}" alt="{{ $previous->slug }}" onerror="this.onerror=null; this.src='{{ asset('images/socialcard.png') }}'">
268268
<div class="flex flex-col space-y-1">
269269
<a class="text-base font-medium leading-4 text-skin-inverted hover:text-skin-primary-hover line-clamp-2" href="{{ route('articles.show', $previous) }}">{{ $previous->title }}</a>
270270
<span class="text-sm text-skin-muted">{{ __(':time min de lecture', ['time' => $previous->readTime()]) }}</span>

resources/views/components/articles/card-with-author.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
{!! $article->excerpt(175) !!}
2525
</p>
2626
<div class="relative h-96 overflow-hidden">
27-
<img class="w-full h-full object-cover shadow-lg rounded-lg group-hover:opacity-75" src="{{ $article->getFirstMediaUrl('media') }}" alt="{{ $article->title }}" />
27+
<img class="w-full h-full object-cover shadow-lg rounded-lg group-hover:opacity-75" src="{{ $article->getFirstMediaUrl('media') }}" alt="{{ $article->title }}" onerror="this.src='{{ asset('images/socialcard.png') }}'" />
2828
</div>
2929
<div class="flex justify-between space-x-8">
3030
<div class="flex space-x-6">

resources/views/components/articles/card.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
>
1313
<a href="{{ route('articles.show', $article) }}" class="group">
1414
<div class="aspect-w-3 aspect-h-2">
15-
<img class="object-cover shadow-lg rounded-lg group-hover:opacity-75" src="{{ $article->getFirstMediaUrl('media') }}" alt="{{ $article->title }}" onerror="this.onerror=null;this.src='{{ getAvatar($article->title) }}'" />
15+
<img class="object-cover shadow-lg rounded-lg group-hover:opacity-75" src="{{ $article->getFirstMediaUrl('media') }}" alt="{{ $article->title }}" onerror="this.onerror=null;this.src='{{ asset('images/socialcard.png') }}'" />
1616
</div>
1717
</a>
1818
<div

resources/views/components/articles/overview.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="aspect-w-3 aspect-h-2">
66
<img class="object-cover shadow-lg rounded-lg group-hover:opacity-75"
77
src="{{ $article->getFirstMediaUrl('media') }}"
8-
alt="{{ $article->title }}"
8+
alt="{{ $article->title }}" onerror="this.src='{{ asset('images/socialcard.png') }}'"
99
/>
1010
</div>
1111
</a>

resources/views/components/forms/single-upload.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<p class="mt-1 text-xs text-skin-muted">
3333
{{ __('PNG, JPG, GIF up to 1MB') }}
3434
</p>
35-
<input @focus="focused = true" @blur="focused = false" class="sr-only" type="file" {{ $attributes }} />
35+
<input @focus="focused = true" @blur="focused = false" class="sr-only" type="file" accept="image/jpg, image/jpeg, image/png" {{ $attributes }} />
3636
</div>
3737
<div class="w-full h-full hidden flex items-center justify-center" wire:loading.class.remove="hidden" wire:target="file">
3838
<x-loader wire:loading wire:target="file" class="text-green-600" />

resources/views/livewire/articles/_form.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
{{ __('Enregistrer') }}
2323
</button>
2424
<span x-data="{ open: false }" @keydown.escape.stop="open = false;" @click.away="open = false" class="-ml-px relative block">
25-
<button type="button" class="relative inline-flex items-center px-2 py-2 rounded-r-md border border-transparent text-sm font-medium text-white text-white bg-green-600 hover:bg-green-700 focus:z-10 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-body focus:ring-green-500"
25+
<button type="button" class="relative inline-flex items-center px-2 py-2 rounded-r-md border border-transparent text-sm font-medium text-white bg-green-600 hover:bg-green-700 focus:z-10 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-body focus:ring-green-500"
2626
id="option-menu-button"
2727
x-ref="button"
2828
@click="open = !open"
@@ -253,7 +253,7 @@ class="flex items-center justify-center text-sm leading-none text-center rounded
253253
wire:model="title"
254254
name="title"
255255
id="title"
256-
class="block w-full h-auto px-0 py-4 text-3xl sm:text-4xl font-bold placeholder-skin-input focus:placeholder-skin-input-focus font-normal text-skin-inverted bg-transparent border-0 leading-normal border-0 appearance-none focus:ring-0 shadow-none"
256+
class="block w-full h-auto px-0 py-4 text-3xl sm:text-4xl font-bold placeholder-skin-input focus:placeholder-skin-input-focus font-normal text-skin-inverted bg-transparent leading-normal border-0 appearance-none focus:ring-0 shadow-none"
257257
placeholder="Titre de votre article..."
258258
autofocus
259259
autocomplete="off"

0 commit comments

Comments
 (0)