feat: WebP and srcset for featured images
- JournalFeaturedImage renders <picture> from featured_images[].variants: a WebP source and the original format as srcset fallback, the original's width and height, alt; lazy in cards, eager with fetchpriority high on the post page; unchanged without variants - app/utils/srcset.ts (imageSrcsets) with node tests - acme fixtures and SSR expectations for both cases
This commit is contained in:
@@ -141,3 +141,12 @@
|
||||
# previous_post and next_post stay.
|
||||
200 /blog/heading-on contains=href="/blog/acme-note-04" class="journal-post__previous" rel="prev"><span>Previous post</span> Acme Note 04</a> contains=href="/blog/acme-note-06" class="journal-post__next" rel="next"><span>Next post</span> Acme Note 06</a>
|
||||
200 /blog/heading-off contains=href="/blog/heading-on" class="journal-post__next" rel="next"><span>Next post</span> Heading On Sample</a> notcontains=journal-post__previous
|
||||
|
||||
# Featured images with the API's variants (D-85, D-71): <picture> with a
|
||||
# WebP source and the original format as the srcset fallback (the
|
||||
# original itself as the widest candidate), the original's width and
|
||||
# height, alt; the post's main image eager with fetchpriority high, cards
|
||||
# lazy. An image without variants renders the single <img> as before.
|
||||
200 /blog/hello-acme contains=<figure class="journal-featured-image"><picture><source contains=image/webp" srcset="/storage/app/uploads/public/acme/thumb_1_480_252_0_0_exact.webp 480w, /storage/app/uploads/public/acme/thumb_1_800_420_0_0_exact.webp 800w" sizes="(min-width: 46rem) 46rem, 100vw"><img src="/storage/app/uploads/public/acme/hello.png" srcset="/storage/app/uploads/public/acme/thumb_1_480_252_0_0_exact.png 480w, /storage/app/uploads/public/acme/thumb_1_800_420_0_0_exact.png 800w, /storage/app/uploads/public/acme/hello.png 1200w" sizes="(min-width: 46rem) 46rem, 100vw" width="1200" height="630" alt="Hello Acme" loading="eager" fetchpriority="high" decoding="async"></picture></figure> count=fetchpriority="high":1
|
||||
200 /blog contains=image/webp" srcset="/storage/app/uploads/public/acme/thumb_1_480_252_0_0_exact.webp 480w, /storage/app/uploads/public/acme/thumb_1_800_420_0_0_exact.webp 800w" sizes="(min-width: 48rem) 33vw, 100vw"> contains=alt="Hello Acme" loading="lazy" decoding="async"></picture> notcontains=fetchpriority
|
||||
200 /blog/acme-note-03 contains=<figure class="journal-featured-image"><img src="/storage/app/uploads/public/acme/note-03.jpg" alt="Acme Note 03" width="1200" height="630" loading="eager" decoding="async"></figure> notcontains=note-03.jpg 1200w notcontains=fetchpriority
|
||||
|
||||
@@ -38,7 +38,25 @@
|
||||
"id": 1,
|
||||
"url": "/storage/app/uploads/public/acme/hello.png",
|
||||
"file_name": "hello.png",
|
||||
"file_size": 1024
|
||||
"file_size": 1024,
|
||||
"variants": [
|
||||
{
|
||||
"width": 480,
|
||||
"height": 252,
|
||||
"url": "/storage/app/uploads/public/acme/thumb_1_480_252_0_0_exact.png",
|
||||
"webp_url": "/storage/app/uploads/public/acme/thumb_1_480_252_0_0_exact.webp",
|
||||
"source_width": 1200,
|
||||
"source_height": 630
|
||||
},
|
||||
{
|
||||
"width": 800,
|
||||
"height": 420,
|
||||
"url": "/storage/app/uploads/public/acme/thumb_1_800_420_0_0_exact.png",
|
||||
"webp_url": "/storage/app/uploads/public/acme/thumb_1_800_420_0_0_exact.webp",
|
||||
"source_width": 1200,
|
||||
"source_height": 630
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"featured_image_url": "/storage/app/uploads/public/acme/hello.png",
|
||||
@@ -108,8 +126,15 @@
|
||||
}
|
||||
],
|
||||
"tags": [],
|
||||
"featured_images": [],
|
||||
"featured_image_url": null,
|
||||
"featured_images": [
|
||||
{
|
||||
"id": 3,
|
||||
"url": "/storage/app/uploads/public/acme/note-03.jpg",
|
||||
"file_name": "note-03.jpg",
|
||||
"file_size": 2048
|
||||
}
|
||||
],
|
||||
"featured_image_url": "/storage/app/uploads/public/acme/note-03.jpg",
|
||||
"translations": {},
|
||||
"created_at": "2026-01-12T09:00:00+00:00",
|
||||
"updated_at": "2026-01-12T09:00:00+00:00"
|
||||
|
||||
Reference in New Issue
Block a user