If the Featured Product block was added but not modified at all,
the block would not match the editor on the front end.

This was due to the fact that, on the frontend, the
block is SSR and was missing some defaults which
were present in JS.
This commit is contained in:
Lucio Giannotta 2022-04-19 15:57:05 +02:00 committed by GitHub
parent 54fba3fe4e
commit 9b6d0e0e0f
1 changed files with 5 additions and 2 deletions

View File

@ -25,9 +25,10 @@ class FeaturedProduct extends AbstractDynamicBlock {
'dimRatio' => 50,
'focalPoint' => false,
'imageFit' => 'none',
'minHeight' => false,
'minHeight' => 500,
'mediaId' => 0,
'mediaSrc' => '',
'overlayColor' => '#000000',
'showDesc' => true,
'showPrice' => true,
);
@ -185,8 +186,10 @@ class FeaturedProduct extends AbstractDynamicBlock {
public function get_styles( $attributes ) {
$style = '';
$min_height = isset( $attributes['minHeight'] ) ? $attributes['minHeight'] : wc_get_theme_support( 'featured_block::default_height', 500 );
if ( isset( $attributes['minHeight'] ) ) {
$style .= sprintf( 'min-height:%dpx;', intval( $attributes['minHeight'] ) );
$style .= sprintf( 'min-height:%dpx;', intval( $min_height ) );
}
$global_style_style = StyleAttributesUtils::get_styles_by_attributes( $attributes, $this->global_style_wrapper );