diff -r be944660c56a -r 3d72ae0968f4 wp/wp-includes/blocks/post-featured-image.php --- a/wp/wp-includes/blocks/post-featured-image.php Wed Sep 21 18:19:35 2022 +0200 +++ b/wp/wp-includes/blocks/post-featured-image.php Tue Sep 27 16:37:53 2022 +0200 @@ -19,18 +19,36 @@ } $post_ID = $block->context['postId']; - $featured_image = get_the_post_thumbnail( $post_ID ); + $size_slug = isset( $attributes['sizeSlug'] ) ? $attributes['sizeSlug'] : 'post-thumbnail'; + $post_title = trim( strip_tags( get_the_title( $post_ID ) ) ); + $featured_image = get_the_post_thumbnail( $post_ID, $size_slug, array( 'alt' => $post_title ) ); if ( ! $featured_image ) { return ''; } - + $wrapper_attributes = get_block_wrapper_attributes(); if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) { $featured_image = sprintf( '%2s', get_the_permalink( $post_ID ), $featured_image ); } - $wrapper_attributes = get_block_wrapper_attributes(); + $has_width = ! empty( $attributes['width'] ); + $has_height = ! empty( $attributes['height'] ); + if ( ! $has_height && ! $has_width ) { + return "
$featured_image
"; + } + + if ( $has_width ) { + $wrapper_attributes = get_block_wrapper_attributes( array( 'style' => "width:{$attributes['width']};" ) ); + } - return '
' . $featured_image . '
'; + if ( $has_height ) { + $image_styles = "height:{$attributes['height']};"; + if ( ! empty( $attributes['scale'] ) ) { + $image_styles .= "object-fit:{$attributes['scale']};"; + } + $featured_image = str_replace( 'src=', 'style="' . esc_attr( $image_styles ) . '" src=', $featured_image ); + } + + return "
$featured_image
"; } /**