Skip to content

Commit

Permalink
Try to fix Post Featured Image sizing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Apr 20, 2023
1 parent bd47ab1 commit 15bef96
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions packages/block-library/src/post-featured-image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand All @@ -110,7 +110,8 @@ export default function PostFeaturedImageEdit( {
) }
withIllustration={ true }
style={ {
...blockProps.style,
height: !! aspectRatio && '100%',
width: !! aspectRatio && '100%',
...borderProps.style,
} }
>
Expand Down Expand Up @@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/post-featured-image/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<figure {$wrapper_attributes}>{$featured_image}</figure>";
}
Expand Down

0 comments on commit 15bef96

Please sign in to comment.