Skip to content

fix(prose): render relative media_ image src from preview origin - #1226

Merged
tripodsan merged 1 commit into
mainfrom
mediasrc
Aug 10, 2026
Merged

fix(prose): render relative media_ image src from preview origin#1226
tripodsan merged 1 commit into
mainfrom
mediasrc

Conversation

@tripodsan

Copy link
Copy Markdown
Contributor

Summary

  • Documents store image src as a path relative to the published page (./media_...), which only resolves once the page is served from its preview/live origin.
  • The prose editor UI runs on a different origin, so those images 404 while editing.
  • mediaBusImage.js now rewrites the rendered <img> src to the doc's https://main--{site}--{org}.preview.da.live/media_... origin for display only, via a view()/update() DOM patch — the underlying document node attrs (and thus the saved source) keep the relative path unchanged.
  • No changes needed to index.js beyond the plugin wiring that was already in place, nor to imageFocalPoint.js (avoided a competing nodeViews.image registration, which would have silently broken focal-point editing).

Test plan

  • Added test/unit/blocks/edit/prose/plugins/mediaBusImage.test.js covering the src-rewrite helper and end-to-end rendering (asserts the rendered <img> src is rewritten while the doc's attrs.src stays relative; non-media srcs are left untouched).
  • Full unit suite passes (npm test): 1799 passed, 0 failed, 4 skipped.
  • Manual check in a browser: open a doc with a relative ./media_... image in the prose editor and confirm it renders in both an editable and a read-only (no write permission) session, and that the saved document source still contains the relative path.

🤖 Generated with Claude Code

Documents store image src as a path relative to the published page
(./media_...), which only resolves once served from the site's
preview/live origin. The prose editor UI runs on a different origin,
so those images 404 while editing. Rewrite the rendered <img> src to
the doc's preview origin for display only, leaving the saved
(relative) src untouched.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@aem-code-sync

aem-code-sync Bot commented Aug 10, 2026

Copy link
Copy Markdown

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
In case there are problems, just click the checkbox below to rerun the respective action.

  • Re-sync branch
Commits

@tripodsan
tripodsan requested a review from kptdobe August 10, 2026 12:23

@kptdobe kptdobe 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.

Nice!

@tripodsan
tripodsan merged commit 47acf3a into main Aug 10, 2026
4 of 7 checks passed
@tripodsan
tripodsan deleted the mediasrc branch August 10, 2026 16:04
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.

2 participants