Skip to content

Managing page media

In the admin: Page media — the screen this page documents (opens in the running app).

What/why: Content & media — what this screen manages and why it exists.

Purpose: set the media for page-chrome slots — the home hero and component banners — from the media library, per slot, with no rebuild or deploy.

When to use

  • Putting a photo or video hero on the home page (or swapping the current one).
  • Adding an optional banner to a page component (e.g. the "How it works" section).
  • Clearing a slot so the page reverts to its text-only presentation.

Prerequisites

  • Admin access with the edit_data capability (any data_editor or admin role).
  • An asset to assign — pick one already in the media library, or create it in place: the slot's shared chooser (#1697) can upload an image or add a video URL right there.

Steps

  1. Open Admin → Page media (/admin/page-media). Slots are grouped by page; each shows its current assignment (a thumbnail and "Assigned" badge) or "Not set".
  2. On the slot you want to change, use the shared chooser — Upload image, Add video URL, or Pick from library (search or filter by type, then choose an asset).
  3. The selected asset appears as a pending choice — click Apply to assign it (or Cancel to discard). To remove an existing assignment, click Clear on that slot.
  4. The change is stored in D1 (app_settings, key media.<page>.<slot>, value a media_assets.id) and takes effect on the next page load. Each apply and clear is recorded in the audit trail (entity page_media, entity id the slot key).

Behavior guarantees

  • Graceful fallback. An unset slot — or one whose asset was later deleted — renders nothing; the page shows its text hero / text-only section instead of a broken image. Page media is a garnish, never a dependency (the home page is static-first).
  • Image or video. A video assignment renders as the still-that-plays (poster image, click-to-play) — no autoplay, so it honors reduced-motion, and the fixed aspect frame means no layout shift.
  • Validated writes. Only a registered slot and a real asset can be persisted; an unknown slot or a stale id is rejected rather than stored.

Adding a slot

Slots are a registry, not a schema — adding one needs no migration. Add an entry to PAGE_MEDIA_SLOTS in src/lib/page-media/index.ts (its key, admin label, page, and description) and render it on the target page via the getPageMedia load and the EntityHeroMedia dispatcher — the store, this admin editor, and the audit trail pick it up automatically. See the Theming reference for the shared app_settings architecture.