[List View] Image preview to use URL connected to block binding#77855
[List View] Image preview to use URL connected to block binding#77855BugReportOnWeb wants to merge 2 commits intoWordPress:trunkfrom
Conversation
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
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. |
What?
Closes #75163
This PR fixes two related issues with the List View image preview for
core/imageblocks when theurlattribute is connected to a block binding source:urlis switched to a block binding, the List View continues to show the old media library image.urlwithout first selecting an image, the List View shows no preview at all.Why?
use-list-view-images.jswas reading image URLs directly from raw block attributes. When a block binding is connected to theurlattribute, the raw attributes are not updated.As a result, the List View is unaware of bindings and continues to display stale raw attribute values instead of the live resolved values.
How?
Updated
useListViewImagesto:getImagesFromBlock.Testing Instructions
Register a custom block bindings source using
register_block_bindings_source()(PHP) andwp.blocks.registerBlockBindingsSource()(JS). Example:Create a new post and insert an Image block.
Select any image from the media library.
Open the List View and confirm the correct image preview is shown.
In the block sidebar (Attributes panel), connect the url attribute to your custom binding source.
Insert a second Image block without selecting any image first.
Connect the url attribute to your custom binding source.
Verify that regular image blocks (without bindings) still display previews correctly.
Screenshots or screencast
Use of AI Tools
ChatGPT for rephrasing PR description and Claude 4.6 for understandings basics of block bindings.