Make WordPress Core


Ignore:
Timestamp:
06/27/2023 02:20:18 PM (3 years ago)
Author:
Bernhard Reiter
Message:

Editor: update Wordpress npm packages.

Updates the wordpress npm packages and their dependencies to the latest versions, as well as auto-updates to relevant core PHP files.

Props youknowriad, joemcgill, spacedmonkey, ramonopoly, peterwilsoncc, bernhard-reiter, tyxla, dmsnell.
Fixes #58623.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks/image.php

    r54257 r56065  
    1515 */
    1616function 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
    1725        if ( isset( $attributes['data-id'] ) ) {
    1826                // Add the data-id="$id" attribute to the img element
     
    2028                // which now wraps Image Blocks within innerBlocks.
    2129                // 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'] );
    2631        }
    27         return $content;
     32
     33        return $processor->get_updated_html();
    2834}
    29 
    3035
    3136/**
     
    3338 */
    3439function register_block_core_image() {
     40
    3541        register_block_type_from_metadata(
    3642                __DIR__ . '/image',
Note: See TracChangeset for help on using the changeset viewer.