Skip to content

Commit

Permalink
Show size controls by default
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonjd committed May 8, 2024
1 parent 55e839a commit 00b579d
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ const {
BackgroundPanel: StylesBackgroundPanel,
} = unlock( blockEditorPrivateApis );

/**
* Checks if there is a current value in the background image block support
* attributes.
*
* @param {Object} style Style attribute.
* @return {boolean} Whether the block has a background image value set.
*/
export function hasBackgroundImageValue( style ) {
return (
!! style?.background?.backgroundImage?.id ||
!! style?.background?.backgroundImage?.url ||
typeof style?.background?.backgroundImage === 'string'
);
}

export default function BackgroundPanel() {
const [ style ] = useGlobalStyle( '', undefined, 'user', {
shouldDecodeEncode: false,
Expand All @@ -31,7 +46,9 @@ export default function BackgroundPanel() {

const defaultControls = {
backgroundImage: true,
backgroundSize: false,
backgroundSize:
hasBackgroundImageValue( style ) ||
hasBackgroundImageValue( inheritedStyle ),
};

return (
Expand Down

0 comments on commit 00b579d

Please sign in to comment.