From 118b306b4f726b105a115b02d91f91838d748d65 Mon Sep 17 00:00:00 2001 From: Lucio Giannotta Date: Sun, 10 Apr 2022 01:09:10 +0200 Subject: [PATCH] Implement `minHeight` and `imageFit` on the PHP rendered component --- src/BlockTypes/FeaturedProduct.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/BlockTypes/FeaturedProduct.php b/src/BlockTypes/FeaturedProduct.php index b374c684465..b22d78e2067 100644 --- a/src/BlockTypes/FeaturedProduct.php +++ b/src/BlockTypes/FeaturedProduct.php @@ -24,7 +24,8 @@ class FeaturedProduct extends AbstractDynamicBlock { 'contentAlign' => 'center', 'dimRatio' => 50, 'focalPoint' => false, - 'height' => false, + 'imageFit' => 'none', + 'minHeight' => false, 'mediaId' => 0, 'mediaSrc' => '', 'showDesc' => true, @@ -127,6 +128,8 @@ private function render_image( $attributes, $product ) { $image_size = 'full'; } + $style .= sprintf( 'object-fit: %s;', $attributes['imageFit'] ); + if ( $attributes['mediaId'] ) { $image = wp_get_attachment_image_url( $attributes['mediaId'], $image_size ); } else { @@ -182,8 +185,8 @@ private function render_overlay( $attributes ) { public function get_styles( $attributes ) { $style = ''; - if ( isset( $attributes['height'] ) ) { - $style .= sprintf( 'min-height:%dpx;', intval( $attributes['height'] ) ); + if ( isset( $attributes['minHeight'] ) ) { + $style .= sprintf( 'min-height:%dpx;', intval( $attributes['minHeight'] ) ); } $global_style_style = StyleAttributesUtils::get_styles_by_attributes( $attributes, $this->global_style_wrapper );