From 15bef96db817ec15563ec490597adb1e0f543db1 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Thu, 6 Apr 2023 18:40:19 +0300 Subject: [PATCH] Try to fix Post Featured Image sizing issues --- packages/block-library/src/post-featured-image/edit.js | 7 ++++--- packages/block-library/src/post-featured-image/index.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/post-featured-image/edit.js b/packages/block-library/src/post-featured-image/edit.js index 1fcf7af2b3b146..6b88c96af26073 100644 --- a/packages/block-library/src/post-featured-image/edit.js +++ b/packages/block-library/src/post-featured-image/edit.js @@ -97,7 +97,7 @@ export default function PostFeaturedImageEdit( { } ) ); const blockProps = useBlockProps( { - style: { width, height, aspectRatio }, + style: { width, height, aspectRatio, maxWidth: '100%' }, } ); const borderProps = useBorderProps( attributes ); @@ -110,7 +110,8 @@ export default function PostFeaturedImageEdit( { ) } withIllustration={ true } style={ { - ...blockProps.style, + height: !! aspectRatio && '100%', + width: !! aspectRatio && '100%', ...borderProps.style, } } > @@ -210,7 +211,7 @@ export default function PostFeaturedImageEdit( { const label = __( 'Add a featured image' ); const imageStyles = { ...borderProps.style, - height: ( !! aspectRatio && '100%' ) || height, + height: aspectRatio ? '100%' : height, width: !! aspectRatio && '100%', objectFit: !! ( height || aspectRatio ) && scale, }; diff --git a/packages/block-library/src/post-featured-image/index.php b/packages/block-library/src/post-featured-image/index.php index 6cb4110ee000e6..41de46bf61013b 100644 --- a/packages/block-library/src/post-featured-image/index.php +++ b/packages/block-library/src/post-featured-image/index.php @@ -92,7 +92,7 @@ function render_block_core_post_featured_image( $attributes, $content, $block ) if ( ! $height && ! $width && ! $aspect_ratio ) { $wrapper_attributes = get_block_wrapper_attributes(); } else { - $wrapper_attributes = get_block_wrapper_attributes( array( 'style' => $aspect_ratio . $width . $height ) ); + $wrapper_attributes = get_block_wrapper_attributes( array( 'style' => $aspect_ratio . $width . $height . 'max-width:100%;' ) ); } return "
{$featured_image}
"; }