fix: support link fields as image and video sources#372
Merged
Conversation
Allow CMS link/url fields to be selected and rendered as image and video sources, and fall back to the default placeholder when the bound CMS value is empty. - Add link to IMAGE_FIELD_TYPES so the field selector offers link/url fields for image, background, lightbox and page settings bindings - Unwrap serialized CollectionLinkValue values to the underlying URL or asset id when resolving image/video sources - Return the default image/video placeholder when the resolved CMS value is empty or has no usable URL/asset
The server-side collection render wrapped a link field's serialized CollectionLinkValue as an asset id, so image/video/background sources bound to link/url fields failed to resolve and fell back to the default placeholder on preview and published pages. Unwrap the link value to the underlying URL or asset id before building the variable.
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
CMS link/URL fields could not be used as image or video sources in the builder, and a field-bound media element with an empty CMS value rendered as broken. This lets link/URL fields hold a media URL and falls back to the default placeholder when the value is empty.
Changes
linktoIMAGE_FIELD_TYPESso the field selector offers link/URL fields for image, background, lightbox and page-settings bindingsCollectionLinkValuevalues to the underlying URL or asset id when resolving image and video sourcesTest plan