Skip to content

Elements: Make preview metadata explicit - #9800

Merged
samohovets merged 2 commits into
mainfrom
elements/explicit-preview-metadata
Jul 28, 2026
Merged

Elements: Make preview metadata explicit#9800
samohovets merged 2 commits into
mainfrom
elements/explicit-preview-metadata

Conversation

@samohovets

Copy link
Copy Markdown
Member

Summary

  • define explicit flat poster and video URLs alongside each Element's preview metadata
  • render broadly compatible opaque MP4 previews and derive R2 upload keys from the metadata URLs
  • support rendering and uploading a single Element while preserving unrelated local preview output
  • update the Element template, publishing skills, and metadata tests

Verification

  • bun run build
  • bun run stylecheck
  • cd packages/docs && bun test src/test/elements.test.ts
  • bun run render-element-previews --element=data/horizontal-bar-chart --upload
  • bun run render-element-previews --element=data/product-offer --upload
  • verified the generated videos are H.264/yuv420p and the posters are opaque

@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bugs Ready Ready Preview, Comment Jul 28, 2026 11:54am
remotion Ready Ready Preview, Comment Jul 28, 2026 11:54am

Request Review

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed changes — replaces the transparentPreview boolean with an explicit preview object on every ElementDefinition. URLs are now authoritative data (not derived from slugs), all previews render as opaque MP4/H.264, and the render script supports rendering single Elements via --element=<category>/<slug>.

  • Add ElementPreviewMetadata type with template literal URL types for posterUrl and videoUrl
  • Replace transparentPreview with preview object on every element definition and the template
  • Remove getElementPreviewUrls helper (URLs are now stored directly on definitions)
  • Always render opaque MP4/H.264/yuv420p previews (no more WebM/VP8/yuva420p branch)
  • Derive R2 upload keys from the explicit URLs via getUploadKey() with origin validation
  • Add --element=<category>/<slug> filtering to render and optionally upload a single Element
  • Update scaffold and publish skills for the new flat URL convention

ℹ️ Old R2 assets at the nested path become orphaned

The URL scheme changes from elements/<category>/<slug>/preview.{png,webm} to the flat elements/<category>-<slug>-preview.{png,mp4}. When the new previews are uploaded, the old R2 objects at the nested paths still exist but are no longer referenced. This is harmless but may be worth noting for a future cleanup pass.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) (Claude Opus not used — the program covers this model; add its provider key to run your pick) | 𝕏

video: `https://remotion.media/elements/${definition.slug}/preview.${definition.transparentPreview ? 'webm' : 'mp4'}`,
});
const assetSlug = definition.slug.replaceAll('/', '-');
expect(String(definition.preview.posterUrl)).toBe(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ The String() wrapper is unnecessary here — definition.preview.posterUrl is a string at runtime (the template literal type is compile-time only). Same on line 296 for videoUrl.

@samohovets
samohovets merged commit 7d5f735 into main Jul 28, 2026
16 checks passed
@samohovets
samohovets deleted the elements/explicit-preview-metadata branch July 28, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant