Skip to content

Commit cdef1c7

Browse files
Enhance trivia image loading with responsive srcset and lazy loading
1 parent 2f61096 commit cdef1c7

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

resources/views/trivia.blade.php

+16-8
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,25 @@ class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-[100%] md:-transl
1010

1111
<div class="relative">
1212
<div class="absolute inset-0 z-10 bg-gradient-to-t from-black/80 via-black/40 to-transparent"></div>
13-
<img src="{{ $trivia->cover_image }}" alt="{{ $trivia->topic }}"
14-
class="w-full aspect-[9/12] md:aspect-[16/9] object-cover group-hover:scale-105 group-hover:translate-y-1 transition-all duration-500">
13+
<img src="{{ $trivia->cover_image }}?width=991"
14+
srcset="
15+
{{ $trivia->cover_image }}?width=607 640w,
16+
{{ $trivia->cover_image }}?width=735 768w,
17+
{{ $trivia->cover_image }}?width=991 1024w,
18+
{{ $trivia->cover_image }}?width=834 1025w,
19+
"
20+
loading="lazy"
21+
alt="{{ $trivia->topic }}"
22+
class="w-full aspect-[9/12] md:aspect-[16/9] object-cover group-hover:scale-105 group-hover:translate-y-1 transition-all duration-500">
1523

1624
{{-- Timer Badge --}}
1725
<div class="absolute z-20 space-y-1 top-4 right-4 text-end">
1826
<div
1927
class="inline-flex items-center gap-2 px-3 py-1 text-sm font-semibold text-white bg-red-500 rounded-full">
2028
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" fill="none" viewBox="0 0 24 24"
21-
stroke="currentColor">
29+
stroke="currentColor">
2230
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
23-
d="M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
31+
d="M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
2432
</svg>
2533
{{ $trivia->answers_count }} domande
2634
</div>
@@ -29,9 +37,9 @@ class="inline-flex items-center gap-2 px-3 py-1 text-sm font-semibold text-white
2937
<div
3038
class="flex items-center gap-1 px-3 py-1 text-sm font-semibold text-white rounded-full bg-white/20 backdrop-blur-sm">
3139
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" fill="none" viewBox="0 0 24 24"
32-
stroke="currentColor">
40+
stroke="currentColor">
3341
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
34-
d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" />
42+
d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
3543
</svg>
3644
{{ $trivia->timer }}s per domanda
3745
</div>
@@ -61,9 +69,9 @@ class="text-3xl md:text-4xl font-bold after:!hidden !m-0 leading-tight transitio
6169
<span>Metti alla prova le tue conoscenze!</span>
6270
<span class="flex items-center gap-1 pl-4 border-l border-white/10">
6371
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" fill="none" viewBox="0 0 24 24"
64-
stroke="currentColor">
72+
stroke="currentColor">
6573
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
66-
d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z" />
74+
d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"/>
6775
</svg>
6876
{{ $trivia->played_count ?? 0 }} partecipazioni
6977
</span>

0 commit comments

Comments
 (0)