Media and Text: Add support for pattern overrides - #81280
Open
yashjawale wants to merge 4 commits into
Open
Conversation
Contributor
Author
|
Will attach a backport once the changes are reviewed. |
yashjawale
marked this pull request as ready for review
August 6, 2026 11:53
yashjawale
requested review from
ajitbohra,
fabiankaegy and
spacedmonkey
as code owners
August 6, 2026 11:53
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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.
What?
Part of #76408
This PR adds support for image overrides for Media & Text block (Does not cover the Cover block).
Why?
Pattern overrides weren't supported for Media & Text block and limited the number of layouts user could created. Enabling overrides for this block too increases the diversity of layouts that could be created.
How?
The attibutes were already marked as content attributes in
block.json. This PR adds server side registrations formediaUrl,mediaAlt, andmediaIdas supported block-bindings attributes forcore/media-textthrough theblock_bindings_supported_attributes_core/media-textfilter. (Later need to whitelist the attributes inwordpress-develop& then the use of this filter can be removed.)In
render_block_core_media_text(), resolve the bound values. BecauseWP_Block::replace_html()can't match the block's descendant selectors the callback finds the media figure withWP_HTML_Tag_Processorand either swaps src/alt on an existing img/video, or when the figure is empty (e.g. the pattern was saved without media), builds the media element from the resolved attributes and inserts it into the figure, then removes a temporary id used for targeting. A guard skips empty resolved URLs for the reset case.Also adds test cases for checking the bindings. Although I'm not sure if I've used the right file for it. Happy to make any required changes.
Testing Instructions
Screenshots or screencast
Screen.Recording.2026-08-06.at.4.36.44.PM.mov
Use of AI Tools
Assisted by DeepSeek V4 Flash via OpenCode
All changes tested & reviewed manually.