Skip to content

Commit

Permalink
Hide caption and link controls in image with overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed Jun 24, 2024
1 parent 0463e09 commit c8e46f4
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions packages/block-library/src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,9 @@ export default function Image( {
</InspectorControls>
);

const arePatternOverridesEnabled =
metadata?.bindings?.__default?.source === 'core/pattern-overrides';

const {
lockUrlControls = false,
lockHrefControls = false,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -964,16 +967,20 @@ export default function Image( {
<>
{ controls }
{ img }

<Caption
attributes={ attributes }
setAttributes={ setAttributes }
isSelected={ isSingleSelected }
insertBlocksAfter={ insertBlocksAfter }
label={ __( 'Image caption text' ) }
showToolbarButton={ isSingleSelected && hasNonContentControls }
readOnly={ lockCaption }
/>
{ /* Don't add caption component and controls in images with pattern overrides */ }
{ ! arePatternOverridesEnabled && (
<Caption
attributes={ attributes }
setAttributes={ setAttributes }
isSelected={ isSingleSelected }
insertBlocksAfter={ insertBlocksAfter }
label={ __( 'Image caption text' ) }
showToolbarButton={
isSingleSelected && hasNonContentControls
}
readOnly={ lockCaption }
/>
) }
</>
);
}

0 comments on commit c8e46f4

Please sign in to comment.