diff --git a/packages/block-library/src/post-featured-image/dimension-controls.js b/packages/block-library/src/post-featured-image/dimension-controls.js index b4a14e57647e1..ab6d60a9be598 100644 --- a/packages/block-library/src/post-featured-image/dimension-controls.js +++ b/packages/block-library/src/post-featured-image/dimension-controls.js @@ -59,7 +59,6 @@ const DimensionControls = ( { attributes: { width, height, scale }, setAttributes, } ) => { - const dimensionsAreSet = width && height; const onDimensionChange = ( dimension, nextValue ) => { setAttributes( { [ dimension ]: parseFloat( nextValue ) < 0 ? '0' : nextValue, @@ -92,7 +91,7 @@ const DimensionControls = ( { /> - { dimensionsAreSet && ( + { !! height && ( <> ); } diff --git a/packages/block-library/src/post-featured-image/index.php b/packages/block-library/src/post-featured-image/index.php index 05d5c889619e4..21e6aca445062 100644 --- a/packages/block-library/src/post-featured-image/index.php +++ b/packages/block-library/src/post-featured-image/index.php @@ -38,17 +38,14 @@ function render_block_core_post_featured_image( $attributes, $content, $block ) $wrapper_attributes = get_block_wrapper_attributes( array( 'style' => "width:{$attributes['width']};" ) ); } - $image_styles = ''; if ( $has_height ) { $image_styles = "height:{$attributes['height']};"; - } - if ( $has_height && $has_width && ! empty( $attributes['scale'] ) ) { - $image_styles .= "object-fit:{$attributes['scale']};"; - } - - if ( $image_styles ) { + if ( ! empty( $attributes['scale'] ) ) { + $image_styles .= "object-fit:{$attributes['scale']};"; + } $featured_image = str_replace( 'src=', "style='$image_styles' src=", $featured_image ); } + return "
$featured_image
"; }