diff --git a/src/wp-includes/class-wp-block.php b/src/wp-includes/class-wp-block.php index 732e0e347052f..57db98d2ee6cd 100644 --- a/src/wp-includes/class-wp-block.php +++ b/src/wp-includes/class-wp-block.php @@ -109,7 +109,7 @@ class WP_Block { private const BLOCK_BINDINGS_SUPPORTED_ATTRIBUTES = array( 'core/paragraph' => array( 'content' ), 'core/heading' => array( 'content' ), - 'core/image' => array( 'id', 'url', 'title', 'alt' ), + 'core/image' => array( 'id', 'url', 'title', 'alt', 'caption' ), 'core/button' => array( 'url', 'text', 'linkTarget', 'rel' ), 'core/post-date' => array( 'datetime' ), ); diff --git a/tests/phpunit/tests/block-bindings/render.php b/tests/phpunit/tests/block-bindings/render.php index d640e7d5207e4..fa8178cbd39b2 100644 --- a/tests/phpunit/tests/block-bindings/render.php +++ b/tests/phpunit/tests/block-bindings/render.php @@ -102,6 +102,16 @@ public function data_update_block_with_value_from_source() { , '
test source value
', ), + 'image block' => array( + 'caption', + << +
Breakfast at a café in Wrocław.
+ +HTML + , + '
test source value
', + ), 'test block' => array( 'myAttribute', << -
+ +
HTML; $parsed_blocks = parse_blocks( $block_content ); @@ -314,7 +332,12 @@ public function test_update_block_with_value_from_source_image_placeholder() { "The 'url' attribute should be updated with the value returned by the source." ); $this->assertSame( - '
', + 'Example Image', + $block->attributes['caption'], + "The 'caption' attribute should be updated with the value returned by the source." + ); + $this->assertSame( + '
Example Image
', trim( $result ), 'The block content should be updated with the value returned by the source.' );