Changeset 52042 for trunk/src/wp-includes/blocks/post-featured-image.php
- Timestamp:
- 11/08/2021 02:26:27 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/post-featured-image.php
r50945 r52042 24 24 return ''; 25 25 } 26 26 $wrapper_attributes = get_block_wrapper_attributes(); 27 27 if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) { 28 28 $featured_image = sprintf( '<a href="%1s">%2s</a>', get_the_permalink( $post_ID ), $featured_image ); 29 29 } 30 30 31 $wrapper_attributes = get_block_wrapper_attributes(); 31 $has_width = ! empty( $attributes['width'] ); 32 $has_height = ! empty( $attributes['height'] ); 33 if ( ! $has_height && ! $has_width ) { 34 return "<figure $wrapper_attributes>$featured_image</figure>"; 35 } 32 36 33 return '<figure ' . $wrapper_attributes . '>' . $featured_image . '</figure>'; 37 if ( $has_width ) { 38 $wrapper_attributes = get_block_wrapper_attributes( array( 'style' => "width:{$attributes['width']};" ) ); 39 } 40 41 if ( $has_height ) { 42 $image_styles = "height:{$attributes['height']};"; 43 if ( ! empty( $attributes['scale'] ) ) { 44 $image_styles .= "object-fit:{$attributes['scale']};"; 45 } 46 $featured_image = str_replace( 'src=', "style='$image_styles' src=", $featured_image ); 47 } 48 49 return "<figure $wrapper_attributes>$featured_image</figure>"; 34 50 } 35 51
Note: See TracChangeset
for help on using the changeset viewer.