From c8e46f4235d5ba7bf3f271cb0d0c1c865439d05c Mon Sep 17 00:00:00 2001 From: Mario Santos Date: Mon, 24 Jun 2024 11:34:44 +0200 Subject: [PATCH] Hide caption and link controls in image with overrides --- packages/block-library/src/image/image.js | 29 ++++++++++++++--------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/packages/block-library/src/image/image.js b/packages/block-library/src/image/image.js index 6095ef2fee24d..32e05f968935b 100644 --- a/packages/block-library/src/image/image.js +++ b/packages/block-library/src/image/image.js @@ -426,6 +426,9 @@ export default function Image( { ); + const arePatternOverridesEnabled = + metadata?.bindings?.__default?.source === 'core/pattern-overrides'; + const { lockUrlControls = false, lockHrefControls = false, @@ -470,7 +473,7 @@ export default function Image( { lockHrefControls: // Disable editing the link of the URL if the image is inside a pattern instance. // This is a temporary solution until we support overriding the link on the frontend. - hasParentPattern, + hasParentPattern || arePatternOverridesEnabled, lockCaption: // Disable editing the caption if the image is inside a pattern instance. // This is a temporary solution until we support overriding the caption on the frontend. @@ -964,16 +967,20 @@ export default function Image( { <> { controls } { img } - - + { /* Don't add caption component and controls in images with pattern overrides */ } + { ! arePatternOverridesEnabled && ( + + ) } ); }