diff --git a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/image/style.scss b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/image/style.scss index 6ab79d4bad2..7c08d449ee6 100644 --- a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/image/style.scss +++ b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/image/style.scss @@ -60,8 +60,6 @@ .wc-block-components-product-image { margin: 0 0 $gap-small; - position: relative; - z-index: -1; } .wc-block-product-image__tools-panel .components-input-control { diff --git a/plugins/woocommerce-blocks/src/BlockTypes/ProductImage.php b/plugins/woocommerce-blocks/src/BlockTypes/ProductImage.php index 79748de50af..dec6318490b 100644 --- a/plugins/woocommerce-blocks/src/BlockTypes/ProductImage.php +++ b/plugins/woocommerce-blocks/src/BlockTypes/ProductImage.php @@ -148,7 +148,16 @@ class ProductImage extends AbstractBlock { private function render_image( $product, $attributes ) { $image_size = 'single' === $attributes['imageSizing'] ? 'woocommerce_single' : 'woocommerce_thumbnail'; - $image_style = sprintf( 'max-width:none; height:%s; width:%s; object-fit:%s;', $attributes['height'] ?? '', $attributes['width'] ?? '', $attributes['scale'] ?? '' ); + $image_style = 'max-width:none;'; + if ( ! empty( $attributes['height'] ) ) { + $image_style .= sprintf( 'height:%s;', $attributes['height'] ); + } + if ( ! empty( $attributes['width'] ) ) { + $image_style .= sprintf( 'width:%s;', $attributes['width'] ); + } + if ( ! empty( $attributes['scale'] ) ) { + $image_style .= sprintf( 'object-fit:%s;', $attributes['scale'] ); + } if ( ! $product->get_image_id() ) { // The alt text is left empty on purpose, as it's considered a decorative image.