-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Open
Labels
[Block] Post Featured ImageAffects the Post Featured Image BlockAffects the Post Featured Image Block[Type] EnhancementA suggestion for improvement.A suggestion for improvement.
Description
Description
If i use the following block I get PHP warnings in core:
<!-- wp:post-featured-image {isLink":true,"sizeSlug":"medium"} /-->The addition of sizeSlug is the instigator, and it's related to the className attribute.
I can resolve this by using the render_block_data to filter the block data and ensure that if className is unset it has an empty string value:
function render_block_data( array $parsed_block ) : array {
if ( $parsed_block['blockName'] === 'core/post-featured-image' ) {
if ( ! isset( $parsed_block['attrs']['className'] ) ) {
$parsed_block['attrs']['className'] = '';
}
}
}This is the warning:
array_key_exists() expects parameter 2 to be array, null given
And it appears in 2 locations in core every time the block is rendered:
wp-includes/block-supports/align.php:48
wp_apply_alignment_support()
wp-includes/class-wp-block-supports.php:119
WP_Block_Supports->apply_block_supports()
wp-includes/class-wp-block-supports.php:176
get_block_wrapper_attributes()
wp-includes/blocks/post-featured-image.php:77
render_block_core_post_featured_image()
wp-includes/class-wp-block.php:258
WP_Block->render()
wp-includes/class-wp-block.php:244
WP_Block->render()
wp-includes/blocks.php:1051
render_block()
wp-includes/blocks.php:1089
do_blocks()
wp-includes/blocks/template-part.php:146
render_block_core_template_part()
wp-includes/class-wp-block.php:258
WP_Block->render()
wp-includes/class-wp-block.php:244
WP_Block->render()
wp-includes/blocks/post-template.php:98
render_block_core_post_template()
wp-includes/class-wp-block.php:258
WP_Block->render()
wp-includes/class-wp-block.php:244
WP_Block->render()
wp-includes/class-wp-block.php:244
WP_Block->render()
wp-includes/class-wp-block.php:244
WP_Block->render()
wp-includes/class-wp-block.php:244
WP_Block->render()
wp-includes/blocks.php:1051
render_block()
wp-includes/blocks.php:1089
do_blocks()
wp-includes/block-template.php:240
get_the_block_template_html()
wp-includes/template-canvas.php:12
and:
wp-includes/block-supports/custom-classname.php:48
wp_apply_custom_classname_support()
wp-includes/class-wp-block-supports.php:119
WP_Block_Supports->apply_block_supports()
wp-includes/class-wp-block-supports.php:176
get_block_wrapper_attributes()
wp-includes/blocks/post-featured-image.php:77
render_block_core_post_featured_image()
wp-includes/class-wp-block.php:258
WP_Block->render()
wp-includes/class-wp-block.php:244
WP_Block->render()
wp-includes/blocks.php:1051
render_block()
wp-includes/blocks.php:1089
do_blocks()
wp-includes/blocks/template-part.php:146
render_block_core_template_part()
wp-includes/class-wp-block.php:258
WP_Block->render()
wp-includes/class-wp-block.php:244
WP_Block->render()
wp-includes/blocks/post-template.php:98
render_block_core_post_template()
wp-includes/class-wp-block.php:258
WP_Block->render()
wp-includes/class-wp-block.php:244
WP_Block->render()
wp-includes/class-wp-block.php:244
WP_Block->render()
wp-includes/class-wp-block.php:244
WP_Block->render()
wp-includes/class-wp-block.php:244
WP_Block->render()
wp-includes/blocks.php:1051
render_block()
wp-includes/blocks.php:1089
do_blocks()
wp-includes/block-template.php:240
get_the_block_template_html()
wp-includes/template-canvas.php:12
Step-by-step reproduction instructions
Try to use a sizeSlug attribute on a featured image block in a block theme
Screenshots, screen recording, code snippet
No response
Environment info
WP 6.2 with a block theme
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
[Block] Post Featured ImageAffects the Post Featured Image BlockAffects the Post Featured Image Block[Type] EnhancementA suggestion for improvement.A suggestion for improvement.