Changeset 56065 for trunk/src/wp-includes/blocks/image.php
- Timestamp:
- 06/27/2023 02:20:18 PM (3 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/blocks/image.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/image.php
r54257 r56065 15 15 */ 16 16 function render_block_core_image( $attributes, $content ) { 17 18 $processor = new WP_HTML_Tag_Processor( $content ); 19 $processor->next_tag( 'img' ); 20 21 if ( $processor->get_attribute( 'src' ) === null ) { 22 return ''; 23 } 24 17 25 if ( isset( $attributes['data-id'] ) ) { 18 26 // Add the data-id="$id" attribute to the img element … … 20 28 // which now wraps Image Blocks within innerBlocks. 21 29 // The data-id attribute is added in a core/gallery `render_block_data` hook. 22 $data_id_attribute = 'data-id="' . esc_attr( $attributes['data-id'] ) . '"'; 23 if ( ! str_contains( $content, $data_id_attribute ) ) { 24 $content = str_replace( '<img', '<img ' . $data_id_attribute . ' ', $content ); 25 } 30 $processor->set_attribute( 'data-id', $attributes['data-id'] ); 26 31 } 27 return $content; 32 33 return $processor->get_updated_html(); 28 34 } 29 30 35 31 36 /** … … 33 38 */ 34 39 function register_block_core_image() { 40 35 41 register_block_type_from_metadata( 36 42 __DIR__ . '/image',
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)