Media performance tools: image/video props, upload placeholders, images preset, YouTube facade

Headless helpers for the project's own <Media> (look stays in the project):
- mediaImageProps: dimensions from the doc (no CLS), lazy by default, LCP image
  gets preload + fetchPriority=high + eager (Next 16 replaced 'priority'),
  focal point → object-position, blur placeholder + dominant colour.
- MEDIA_SIZES suggestions for 'sizes' (any string still works).
- videoProps: 'background' (muted loop, respects reduced motion) or 'player'
  (controls, preload=none, poster).
- buildMediaPlaceholderHook/Field: tiny WebP blur + dominant colour at upload
  via the configured sharp (no new dependency).
- buildImagesConfig: AVIF/WebP, R2 remotePatterns, 31-day cache.
- <YouTubeEmbed> (/client): poster + button, youtube-nocookie iframe on click.
- buildCsp youtube allows the i.ytimg.com poster. kod-sekcji Media template
  uses the helpers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-16 03:19:38 +02:00
co-authored by Claude Opus 5.5
parent f7466cf77f
commit 55fc27a13f
13 changed files with 414 additions and 25 deletions
+4 -4
View File
@@ -79,11 +79,11 @@ describe('archive listing', () => {
describe('noindex protection', () => {
test('the homepage cannot be set to noindex; an ordinary page can', async () => {
const home = await payload.create({ collection: 'pages' as never, data: { _status: 'published', slug: 'start', title: 'Start' } as never })
const other = await payload.create({ collection: 'pages' as never, data: { _status: 'published', slug: 'dziekujemy', title: 'Dziękujemy' } as never })
const home = await payload.create({ collection: 'pages' as never, data: { slug: 'start', _status: 'published', title: 'Start' } as never })
const other = await payload.create({ collection: 'pages' as never, data: { slug: 'dziekujemy', _status: 'published', title: 'Dziękujemy' } as never })
await payload.updateGlobal({ slug: 'site-settings' as never, data: { homepage: home.id, siteName: 'Acme' } as never })
await expect(payload.update({ collection: 'pages' as never, data: { noindex: true } as never, id: home.id })).rejects.toThrow(/Exclude from indexing/)
const updated = (await payload.update({ collection: 'pages' as never, data: { noindex: true } as never, id: other.id })) as { noindex?: boolean }
await expect(payload.update({ id: home.id, collection: 'pages' as never, data: { noindex: true } as never })).rejects.toThrow(/Exclude from indexing/)
const updated = (await payload.update({ id: other.id, collection: 'pages' as never, data: { noindex: true } as never })) as { noindex?: boolean }
expect(updated.noindex).toBe(true)
})
})