Make WordPress Core


Ignore:
Timestamp:
05/10/2022 02:47:10 PM (2 years ago)
Author:
gziolo
Message:

Editor: Update WordPress packages for 6.0 RC 2

Included cherry-picked commits from the Gutenberg plugin that fix bugs discovere after WordPress 6.0 RC 1.

Props zieladam, ndiego, hellofromtonya.
See #55567.

File:
1 edited

Legend:

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

    r53329 r53377  
    1515 */
    1616function render_block_core_cover( $attributes, $content ) {
    17     if ( false === $attributes['useFeaturedImage'] ) {
     17    if ( 'image' !== $attributes['backgroundType'] || false === $attributes['useFeaturedImage'] ) {
    1818        return $content;
    1919    }
    2020
    21     $current_featured_image = get_the_post_thumbnail_url();
     21    if ( ! ( $attributes['hasParallax'] || $attributes['isRepeated'] ) ) {
     22        $attr = array(
     23            'class'           => 'wp-block-cover__image-background',
     24            'data-object-fit' => 'cover',
     25        );
    2226
    23     if ( false === $current_featured_image ) {
    24         return $content;
    25     }
    26 
    27     $is_img_element      = ! ( $attributes['hasParallax'] || $attributes['isRepeated'] );
    28     $is_image_background = 'image' === $attributes['backgroundType'];
    29 
    30     if ( $is_image_background && ! $is_img_element ) {
    31         $content = preg_replace(
    32             '/class=\".*?\"/',
    33             '${0} style="background-image:url(' . esc_url( $current_featured_image ) . ')"',
    34             $content,
    35             1
    36         );
    37     }
    38 
    39     if ( $is_image_background && $is_img_element ) {
    40         $object_position = '';
    4127        if ( isset( $attributes['focalPoint'] ) ) {
    42             $object_position = round( $attributes['focalPoint']['x'] * 100 ) . '%' . ' ' .
    43             round( $attributes['focalPoint']['y'] * 100 ) . '%';
     28            $object_position              = round( $attributes['focalPoint']['x'] * 100 ) . '%' . ' ' . round( $attributes['focalPoint']['y'] * 100 ) . '%';
     29            $attr['data-object-position'] = $object_position;
     30            $attr['style']                = 'object-position: ' . $object_position;
    4431        }
    4532
    46         $image_template = '<img
    47             class="wp-block-cover__image-background"
    48             alt="%s"
    49             src="%s"
    50             style="object-position: %s"
    51             data-object-fit="cover"
    52             data-object-position="%s"
    53         />';
    54 
    55         $image = sprintf(
    56             $image_template,
    57             esc_attr( get_the_post_thumbnail_caption() ),
    58             esc_url( $current_featured_image ),
    59             esc_attr( $object_position ),
    60             esc_attr( $object_position )
    61         );
     33        $image = get_the_post_thumbnail( null, 'post-thumbnail', $attr );
    6234
    6335        $content = str_replace(
     
    6739        );
    6840
     41    } else {
     42        if ( in_the_loop() ) {
     43            update_post_thumbnail_cache();
     44        }
     45        $current_featured_image = get_the_post_thumbnail_url();
     46        $content                = preg_replace(
     47            '/class=\".*?\"/',
     48            '${0} style="background-image:url(' . esc_url( $current_featured_image ) . ')"',
     49            $content,
     50            1
     51        );
    6952    }
    7053
Note: See TracChangeset for help on using the changeset viewer.