Skip to content

Block Bindings: Add support for Media & Text block image#71610

Closed
theminaldiwan wants to merge 1 commit into
WordPress:trunkfrom
theminaldiwan:add-media-text-binding-code
Closed

Block Bindings: Add support for Media & Text block image#71610
theminaldiwan wants to merge 1 commit into
WordPress:trunkfrom
theminaldiwan:add-media-text-binding-code

Conversation

@theminaldiwan
Copy link
Copy Markdown
Contributor

This PR adds block bindings support for the Media & Text block’s mediaId attribute. as this issue mentioned in #68637
With this change, the image inside the Media & Text block can be dynamically sourced (e.g., post featured image, custom fields, or other bindings), rather than being limited to a fixed image or the featured image only.

Why?

Currently, the Media & Text block is useful in templates but restricted in flexibility since the image must either be manually uploaded or set to the featured image.
By enabling block bindings on the mediaId, template authors and developers can connect the block to other dynamic image sources (e.g., post meta, custom fields, reusable bindings), making it far more versatile for building dynamic templates.

How?

  • Added bindings support to the mediaId attribute of the Media & Text block.

And we need to below pattern code

<!-- wp:media-text {"blockBindings":{"mediaId":{"source":"core/post-featured-image"}}} -->
<div class="wp-block-media-text is-stacked-on-mobile">
    <figure class="wp-block-media-text__media"></figure>
    <div class="wp-block-media-text__content">
        <p>This should now display the Featured Image.</p>
    </div>
</div>
<!-- /wp:media-text -->

@github-actions
Copy link
Copy Markdown

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 props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @minaldiwan.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: minaldiwan.


To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Block] Media & Text Affects the Media & Text Block [Feature] Block bindings labels Sep 11, 2025
Copy link
Copy Markdown
Contributor

@cbravobernal cbravobernal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there!

Thanks for contributing. Unfortunately, the code you provided won't make those block attributes bindables 😅 . Please take a look at this PR:

#70642

That won't be merged, but adding new block attributes should be done similarly to that one.

@t-hamano
Copy link
Copy Markdown
Contributor

@theminaldiwan thanks for the PR!

Let's close this PR for now and try a recommended approach if needed.

@t-hamano t-hamano closed this Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Media & Text Affects the Media & Text Block [Feature] Block bindings [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants