← All changes
|
build/scripts/block-library/post-featured-image.php
+4
-1
23.5.0
→
trunk
View file →
| @@ -43,9 +43,12 @@ | ||
| 43 | 43 | $has_width = array_key_exists( 'width', $attributes ) && null !== $attributes['width'] && '' !== $attributes['width']; |
| 44 | 44 | $has_height = array_key_exists( 'height', $attributes ) && null !== $attributes['height'] && '' !== $attributes['height']; |
| 45 | 45 | |
| 46 | 46 | if ( ! empty( $attributes['aspectRatio'] ) ) { |
| 47 | - $extra_styles .= esc_attr( safecss_filter_attr( 'aspect-ratio:' . $attributes['aspectRatio'] ) ) . ';'; | |
| 47 | + // If there's no non-default value set, let the image's width and height attributes determine its intrinsic aspect ratio. | |
| 48 | + if ( 'auto' !== $attributes['aspectRatio'] ) { | |
| 49 | + $extra_styles .= esc_attr( safecss_filter_attr( 'aspect-ratio:' . $attributes['aspectRatio'] ) ) . ';'; | |
| 50 | + } | |
| 48 | 51 | $extra_styles .= 'width:100%;'; |
| 49 | 52 | } |
| 50 | 53 | |
| 51 | 54 | if ( $has_height ) { |