Repository navigation
fix(publisher): resolve custom media fields on entry routes - #662
Draft
rodrigoc-neu-Lab wants to merge 1 commit into
Draft
rodrigoc-neu-Lab wants to merge 1 commit into
rodrigoc-neu-Lab wants to merge 1 commit into
Conversation
On a post-type entry route, `{currentEntry.<field>}` for a custom media
field rendered the raw media id, while the same binding inside a
data.rows loop rendered the /uploads/ path: the entry frame spread raw
cells and only resolved the built-in featuredMedia.
publishedDataRowToEntryItem now resolves the row's media cells with the
same helpers the loop source uses, and every entry-stack caller (public
entry route, branch preview, draft preview) goes through it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On a post-type entry route (
/<routeBase>/<slug>),{currentEntry.<field>}for a custommediafield rendered the raw media id. An image bound with<img src="{currentEntry.heroImage}">published assrc="y36mE-NX00zzcNWE7aSfj".The same binding inside a
data.rowsloop renders/uploads/…, because the loop source resolves every schema-declared media field throughresolvedMediaOverlay. The entry stack is built bypublishedDataRowToLoopItem, which spread the raw cells and resolved only the built-infeaturedMedia. A template author therefore saw working images in a list and broken ones on the matching detail page.This PR:
publishedDataRowToEntryItem(db, row, fields)inserver/publish/loopPrefetch.ts. It resolves the row's media cells with the same helpers the loop source uses (collectMediaIds→resolveMediaIdsToPaths→resolvedMediaOverlay), so single media, multi-media and repeater media behave the same in both places;@core/loopsbarrel instead of deep-importingsources/dataRowsMedia;publishedDataRowToLoopItemprivate and has it take the resolved overlay, leaving one way to build an entry frame;publicRenderer.ts), which read the table throughgetDataTable(MAIN_SCOPE)so the branch-scope architecture gate stays satisfied;branchPreview.ts) and draft previews (handlers/cms/data/preview.ts), which already had the table and pass itsfields.Also documents the behaviour in
docs/features/content-storage.md.mediaPrefetchalready collects resolved/uploads/scalars from the entry stack, so these images now also get their library alt text,srcsetand intrinsic size, likefeaturedMediadoes.Found while migrating a Webflow site: its project and service detail templates bind several custom image fields, and every one of them rendered as an id.
Verification
bun run buildbun test(8 failures intoolbar.test.ts/selectorStability.test.tsalso occur on a cleanorigin/maincheckout. Those tests build paths withnew URL(…).pathname, which percent-encodes a space in the checkout path. They are unrelated to this PR.)bun run lintTests:
loopPrefetch.test.ts: new test showing that scalar and multi-value media fields resolve to public paths and that a missing asset is dropped. The existing authorship test now runs through the new helper.cmsTemplateRoutes.test.ts: the fake DB answers the new table-schema read with no rows, which keeps the existing route fixtures unchanged.Checked by hand on a local install: a template's custom image fields now publish
/uploads/…URLs withsrcset, matching the same entries in loops.Checklist
🤖 Generated with Claude Code