Skip to content

Commit

Permalink
Simplify block schema slightly, make the check for the background.bac…
Browse files Browse the repository at this point in the history
…kgroundImage property
  • Loading branch information
andrewserong committed Sep 7, 2023
1 parent 5173106 commit d501bd6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/block-supports/background.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function gutenberg_register_background_support( $block_type ) {
function gutenberg_render_background_support( $block_content, $block ) {
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
$block_attributes = $block['attrs'];
$has_background_image_support = block_has_support( $block_type, array( 'background' ), false );
$has_background_image_support = block_has_support( $block_type, array( 'background', 'backgroundImage' ), false );

if (
! $has_background_image_support ||
Expand Down
20 changes: 7 additions & 13 deletions schemas/json/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,21 +259,15 @@
"default": false
},
"background": {
"default": false,
"type": "object",
"description": "This value signals that a block supports some of the properties related to background, especially background image. When it does, the block editor will show UI controls for the user to set their values.\n\nWhen the block declares support for a specific background property, its attributes definition is extended to include the style attribute.",
"oneOf": [
{ "type": "boolean" },
{
"type": "object",
"properties": {
"backgroundImage": {
"type": "boolean",
"description": "Exposes a control that allows setting a background image. Background size defaults to `cover`.",
"default": true
}
}
"properties": {
"backgroundImage": {
"type": "boolean",
"description": "Exposes a control that allows setting a background image. Background size defaults to `cover`.",
"default": false
}
]
}
},
"behaviors": {
"type": "object",
Expand Down

0 comments on commit d501bd6

Please sign in to comment.