diff --git a/docs/agent/skills/ipal-block/resources/kod-sekcji.md b/docs/agent/skills/ipal-block/resources/kod-sekcji.md
index 560bfbf..4f8bc93 100644
--- a/docs/agent/skills/ipal-block/resources/kod-sekcji.md
+++ b/docs/agent/skills/ipal-block/resources/kod-sekcji.md
@@ -137,40 +137,40 @@ export function buttonClass(appearance: LinkAppearance): string {
}
```
-`src/components/ui/Media.tsx` — **każdy** obraz/wideo z panelu:
+`src/components/ui/Media.tsx` — **każdy** obraz/wideo z panelu. Szybkość liczy plugin
+(`mediaImageProps`, `videoProps`), wygląd zostaje tutaj:
```tsx
import Image from 'next/image'
+import { mediaImageProps, MEDIA_SIZES, videoProps, type VideoMode } from '@intecion/ipal-kit'
import type { Media as MediaDoc } from '@/payload-types'
type Props = {
resource: MediaDoc | string | number | null | undefined
+ /** Szerokość NA EKRANIE — MEDIA_SIZES.half / .third / własny string. Bez tego pobiera się pełna szerokość. */
sizes?: string
+ /** Tylko pierwszy widoczny obraz strony (hero, LCP). Reszta ładuje się leniwie. */
priority?: boolean
className?: string
- /** Poster image URL for videos (shown before playback). */
- poster?: string
+ /** Wideo: 'background' (pętla bez dźwięku) albo 'player' (kontrolki, ładowanie po kliknięciu). */
+ videoMode?: VideoMode
+ /** Plakat wideo — upload z panelu. */
+ poster?: MediaDoc | string | number | null
}
-export function Media({ resource, sizes = '100vw', priority = false, className, poster }: Props) {
- if (!resource || typeof resource !== 'object' || !resource.url) return null
- const { url, alt, width, height, mimeType } = resource
-
- if (mimeType?.startsWith('video/')) {
- // preload="metadata": the browser fetches only headers until playback, not the whole file
- return (
-
- )
- }
- if (!width || !height) return null // non-image file (PDF) — use CMSLink type 'file'
-
- return (
-
- )
+export function Media({ resource, sizes = MEDIA_SIZES.full, priority = false, className, videoMode = 'player', poster }: Props) {
+ const video = videoProps(resource, { mode: videoMode, poster })
+ if (video) return
+ const img = mediaImageProps(resource, { priority, sizes })
+ if (!img) return null // PDF / plik — link typu 'file' (CMSLink), nie
+ return
}
```
+Media w kolekcji: `upload: { focalPoint: true, … }` (punkt ostrości → `object-position`) oraz
+placeholder z pluginu: `hooks.beforeOperation: [buildOptimizeUploadHook(), buildMediaPlaceholderHook()]`,
+pole `buildMediaPlaceholderField()` (rozmyty podgląd + kolor podczas ładowania).
+
`Section.tsx` i `SectionHeader.tsx`:
```tsx
diff --git a/src/exports/client.ts b/src/exports/client.ts
index 9c7cb8c..dee3f4a 100644
--- a/src/exports/client.ts
+++ b/src/exports/client.ts
@@ -62,6 +62,7 @@ export {
export type { AlternateLinks, LanguageSwitcherClassNames } from '../modules/i18n/index.js'
export { IntegrationStatusBanner } from '../modules/integrations/IntegrationStatusBanner.js'
export { LocaleView } from '../modules/pages/LocaleView.js'
+export { YouTubeEmbed } from '../modules/storage/YouTubeEmbed.js'
export { Turnstile } from '../modules/turnstile/client.js'
export { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js'
export type { TurnstileProps } from '../modules/turnstile/client.js'
diff --git a/src/index.ts b/src/index.ts
index b33aced..db0b092 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -138,6 +138,14 @@ export type {
export { createMcpRoute } from './modules/mcp/index.js'
export { buildOptimizeUploadField, buildOptimizeUploadHook, normalizeFilename, normalizeFilenameHook } from './modules/media/index.js'
export type { OptimizeUploadOptions } from './modules/media/index.js'
+export {
+ buildMediaPlaceholderField,
+ buildMediaPlaceholderHook,
+ MEDIA_SIZES,
+ mediaImageProps,
+ videoProps,
+} from './modules/media/index.js'
+export type { MediaImageOptions, MediaImageProps, VideoMode, VideoProps } from './modules/media/index.js'
export { getNotificationTexts, NOTIFICATION_FALLBACK, resolveFormMessage } from './modules/notifications/index.js'
export type { FormNotificationTexts, NotificationTexts } from './modules/notifications/index.js'
export type { PagesOption, SystemPageRole } from './modules/pages/index.js'
@@ -150,10 +158,10 @@ export {
SITE_INTEGRATIONS_SLUG,
SITE_SETTINGS_SLUG,
} from './modules/payload/index.js'
-
// Lexical → Markdown (pure, no React) — for AI-readable output.
export { lexicalToMarkdown } from './modules/richtext/index.js'
export { buildSecurityHeaders, buildUploadSecurityHeaders } from './modules/security/index.js'
+
export { buildCsp } from './modules/security/index.js'
export type { BuildCspArgs } from './modules/security/index.js'
export type { BuildSecurityHeadersArgs, SecurityHeader } from './modules/security/index.js'
@@ -203,6 +211,8 @@ export type { SitemapRouteOptions, SitemapStyleOptions } from './modules/seo/ind
export { clientIp, setRateLimitStore } from './modules/shared/rateLimit.js'
export type { ClientIpOptions, RateLimitStore } from './modules/shared/rateLimit.js'
export { buildSlugField, toSlug } from './modules/slug/index.js'
+export { buildImagesConfig } from './modules/storage/buildImagesConfig.js'
+export type { ImagesConfig } from './modules/storage/buildImagesConfig.js'
export { buildR2Storage } from './modules/storage/index.js'
// Imported from the file, not the turnstile barrel — that one re-exports verify,
// which imports 'server-only'.
diff --git a/src/modules/media/index.ts b/src/modules/media/index.ts
index cf3c985..2d075aa 100644
--- a/src/modules/media/index.ts
+++ b/src/modules/media/index.ts
@@ -1,3 +1,6 @@
+export { MEDIA_SIZES, mediaImageProps, videoProps } from './mediaProps.js'
+export type { MediaImageOptions, MediaImageProps, VideoMode, VideoProps } from './mediaProps.js'
export { normalizeFilename, normalizeFilenameHook } from './normalizeFilename.js'
export { buildOptimizeUploadField, buildOptimizeUploadHook } from './optimizeUpload.js'
export type { OptimizeUploadOptions } from './optimizeUpload.js'
+export { buildMediaPlaceholderField, buildMediaPlaceholderHook } from './placeholder.js'
diff --git a/src/modules/media/mediaProps.ts b/src/modules/media/mediaProps.ts
new file mode 100644
index 0000000..4f827c8
--- /dev/null
+++ b/src/modules/media/mediaProps.ts
@@ -0,0 +1,136 @@
+/**
+ * Props for the project's own — the plugin computes the performance
+ * details, the project keeps the markup and the look. Nothing here renders,
+ * styles or limits anything: every value can be overridden by the caller.
+ *
+ * // src/components/ui/Media.tsx
+ * const img = mediaImageProps(resource, { sizes: MEDIA_SIZES.half, priority })
+ * if (img) return
+ * const video = videoProps(resource, { mode: 'background' })
+ * if (video) return
+ */
+
+type MediaDoc = {
+ alt?: null | string
+ focalX?: null | number
+ focalY?: null | number
+ height?: null | number
+ mimeType?: null | string
+ placeholder?: { blurDataURL?: null | string; color?: null | string } | null
+ url?: null | string
+ width?: null | number
+}
+
+/**
+ * Starting points for `sizes` — how wide the image is ON SCREEN at each
+ * breakpoint, so the browser downloads the right file instead of a full-width
+ * one. Suggestions only: pass any string that matches the actual layout.
+ */
+export const MEDIA_SIZES = {
+ /** Full-bleed hero / background. */
+ full: '100vw',
+ /** Half the container from md up (two-column hero, image + text). */
+ half: '(min-width: 768px) 50vw, 100vw',
+ /** Card in a 3-column grid from lg, 2 from md. */
+ third: '(min-width: 1024px) 33vw, (min-width: 768px) 50vw, 100vw',
+ /** Card in a 4-column grid. */
+ quarter: '(min-width: 1024px) 25vw, (min-width: 640px) 50vw, 100vw',
+ /** Thumbnail / avatar / logo up to ~160 px. */
+ thumb: '160px',
+} as const
+
+export type MediaImageOptions = {
+ /** Alt override (decorative images: ''). Default: the document's alt. */
+ alt?: string
+ /**
+ * The LCP image (first visible image — usually the hero): loads eagerly with
+ * fetchPriority="high". Exactly one per page; everything else is lazy.
+ */
+ priority?: boolean
+ /** How wide it is on screen. Required in practice — see MEDIA_SIZES. Default '100vw'. */
+ sizes?: string
+}
+
+export type MediaImageProps = {
+ alt: string
+ blurDataURL?: string
+ fetchPriority?: 'high'
+ height: number
+ loading: 'eager' | 'lazy'
+ placeholder?: 'blur' | 'empty'
+ /** Next 16: for the LCP image (replaces the deprecated `priority`). */
+ preload?: boolean
+ sizes: string
+ src: string
+ style?: { backgroundColor?: string; objectPosition?: string }
+ width: number
+}
+
+const asDoc = (resource: unknown): MediaDoc | null =>
+ resource && typeof resource === 'object' && typeof (resource as MediaDoc).url === 'string' ? (resource as MediaDoc) : null
+
+/**
+ * next/image props for an image upload, or null for anything else (video, PDF,
+ * a bare id). Width/height always come from the document — no layout shift.
+ * Focal point (upload `focalPoint: true`) becomes object-position, so a cropped
+ * image keeps its subject; a placeholder (buildMediaPlaceholderHook) becomes a
+ * blur-up and background colour.
+ */
+export function mediaImageProps(resource: unknown, { alt, priority = false, sizes = '100vw' }: MediaImageOptions = {}): MediaImageProps | null {
+ const doc = asDoc(resource)
+ if (!doc || doc.mimeType?.startsWith('video/')) {return null}
+ if (!doc.width || !doc.height) {return null} // PDF or other non-image file — link it instead
+ const blur = doc.placeholder?.blurDataURL ?? undefined
+ const color = doc.placeholder?.color ?? undefined
+ const hasFocal = typeof doc.focalX === 'number' && typeof doc.focalY === 'number' && !(doc.focalX === 50 && doc.focalY === 50)
+ const style = {
+ ...(hasFocal ? { objectPosition: `${doc.focalX}% ${doc.focalY}%` } : {}),
+ ...(color ? { backgroundColor: color } : {}),
+ }
+ return {
+ alt: alt ?? doc.alt ?? '',
+ height: doc.height,
+ sizes,
+ src: doc.url!,
+ width: doc.width,
+ ...(priority
+ ? { fetchPriority: 'high' as const, loading: 'eager' as const, preload: true }
+ : { loading: 'lazy' as const }),
+ ...(blur ? { blurDataURL: blur, placeholder: 'blur' as const } : {}),
+ ...(Object.keys(style).length ? { style } : {}),
+ }
+}
+
+export type VideoMode = 'background' | 'player'
+
+export type VideoProps = {
+ autoPlay?: boolean
+ controls?: boolean
+ loop?: boolean
+ muted?: boolean
+ playsInline: true
+ poster?: string
+ preload: 'metadata' | 'none'
+ src: string
+}
+
+/**
+ *