diff --git a/lib/block-supports/layout.php b/lib/block-supports/layout.php index ca75f479dd67b..ddbd1917c3054 100644 --- a/lib/block-supports/layout.php +++ b/lib/block-supports/layout.php @@ -1106,14 +1106,15 @@ function gutenberg_restore_image_outer_container( $block_content, $block ) { $wrapper_classnames = array( 'wp-block-image' ); - // If the block has a classNames attribute these classnames need to be added back + // If the block has a classNames attribute these classnames need to be removed from the content and added back // to the new wrapper div also. if ( ! empty( $block['attrs']['className'] ) ) { $wrapper_classnames = array_merge( $wrapper_classnames, explode( ' ', $block['attrs']['className'] ) ); } + $content_classnames = explode( ' ', $matches[2] ); + $filtered_content_classnames = array_diff( $content_classnames, $wrapper_classnames ); - // Wrap the existing content with the new wrapper div. - return '