- Timestamp:
- 11/11/2022 02:54:01 PM (2 years ago)
- Location:
- branches/6.1
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/6.1
-
branches/6.1/src/wp-includes/blocks/post-featured-image.php
r54694 r54812 30 30 } 31 31 32 if ( ! empty( $attributes['height'] ) ) { 33 $extra_styles = "height:{$attributes['height']};"; 34 if ( ! empty( $attributes['scale'] ) ) { 35 $extra_styles .= "object-fit:{$attributes['scale']};"; 36 } 37 $attr['style'] = empty( $attr['style'] ) ? $extra_styles : $attr['style'] . $extra_styles; 38 } 39 32 40 $featured_image = get_the_post_thumbnail( $post_ID, $size_slug, $attr ); 33 41 if ( ! $featured_image ) { 34 42 return ''; 35 43 } 36 $wrapper_attributes = get_block_wrapper_attributes();37 44 if ( $is_link ) { 38 45 $link_target = $attributes['linkTarget']; … … 50 57 } 51 58 52 $has_width = ! empty( $attributes['width'] ); 53 $has_height = ! empty( $attributes['height'] ); 54 if ( ! $has_height && ! $has_width ) { 55 return "<figure {$wrapper_attributes}>{$featured_image}</figure>"; 56 } 57 58 if ( $has_width ) { 59 $wrapper_attributes = get_block_wrapper_attributes( array( 'style' => "width:{$attributes['width']};" ) ); 60 } 61 62 if ( $has_height ) { 63 $image_styles = "height:{$attributes['height']};"; 64 if ( ! empty( $attributes['scale'] ) ) { 65 $image_styles .= "object-fit:{$attributes['scale']};"; 66 } 67 $featured_image = str_replace( '<img ', '<img style="' . esc_attr( safecss_filter_attr( $image_styles ) ) . '" ', $featured_image ); 68 } 59 $wrapper_attributes = empty( $attributes['width'] ) 60 ? get_block_wrapper_attributes() 61 : get_block_wrapper_attributes( array( 'style' => "width:{$attributes['width']};" ) ); 69 62 70 63 return "<figure {$wrapper_attributes}>{$featured_image}</figure>";
Note: See TracChangeset
for help on using the changeset viewer.