Skip to content

feat(publisher): optimize media background images#174

Open
DavidBabinec wants to merge 2 commits into
mainfrom
feat/background-image-image-set
Open

feat(publisher): optimize media background images#174
DavidBabinec wants to merge 2 commits into
mainfrom
feat/background-image-image-set

Conversation

@DavidBabinec

Copy link
Copy Markdown
Contributor

What changed

  • Added a shared publisher background-image optimizer that rewrites local /uploads/... CSS backgrounds to optimized variant fallbacks plus image-set(...) candidates.
  • Fed resolved media variants through published inline styles, class CSS, static/public render paths, row previews, CSS bundle fallback rebuilds, and publish-time CSS asset collection.
  • Extended the editor canvas path so inline backgrounds, read-only composed trees, class CSS, style previews, forced-state previews, and sandboxed module class CSS use the same optimized background handling.
  • Added focused coverage for publisher CSS emission, canvas class CSS, editor React style conversion, and server-side batched media prefetching.
  • Updated the publisher documentation to describe responsive CSS background behavior.

Why

Image and video modules already avoid loading original multi-megabyte uploads by using media variants. Background images stored in style bags still emitted raw url('/uploads/original.png'), so a large media-library PNG could be downloaded directly when used as a background.

Impact

When a CMS media asset has generated variants, published and editor-rendered CSS backgrounds now avoid the original upload and let the browser choose from optimized variant candidates. Assets without variants continue to fall back to the stored original URL, matching the existing image fallback behavior.

Verification

  • bun test -> 5961 pass, 0 fail
  • bun run lint -> exit 0
  • bun run build -> exit 0
  • bun test src/__tests__/canvas/classStyleInjector.test.ts src/__tests__/editor/readOnlyNodeTree.test.tsx src/__tests__/publisher/classStyleInjector.test.ts src/__tests__/server/mediaBatchResolution.test.ts -> 92 pass, 0 fail
  • bun run doctor -- --verbose --diff -> warning-only diagnostics in changed files; reviewed as existing/project-approved patterns or non-blocking doctor guidance, no error-tier findings

@DavidBabinec DavidBabinec marked this pull request as ready for review July 3, 2026 08:23
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