Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Implement minHeight and imageFit on the PHP rendered component
Browse files Browse the repository at this point in the history
  • Loading branch information
sunyatasattva committed Apr 11, 2022
1 parent 2cf4dc9 commit 118b306
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/BlockTypes/FeaturedProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit 118b306

Please sign in to comment.