diff --git a/packages/block-library/src/media-text/edit.js b/packages/block-library/src/media-text/edit.js
index 41d33ab14e4e5..5a88830d385d1 100644
--- a/packages/block-library/src/media-text/edit.js
+++ b/packages/block-library/src/media-text/edit.js
@@ -137,7 +137,7 @@ function attributesFromMedia( {
};
}
-function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
+function MediaTextEdit( { attributes, isSelected, setAttributes, clientId } ) {
const {
focalPoint,
href,
@@ -157,12 +157,24 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
} = attributes;
const mediaSizeSlug = attributes.mediaSizeSlug || DEFAULT_MEDIA_SIZE_SLUG;
- const image = useSelect(
- ( select ) =>
- mediaId && isSelected
- ? select( coreStore ).getMedia( mediaId, { context: 'view' } )
- : null,
- [ isSelected, mediaId ]
+ const { imageSizes, image, isContentLocked } = useSelect(
+ ( select ) => {
+ const { __unstableGetContentLockingParent, getSettings } =
+ select( blockEditorStore );
+ return {
+ isContentLocked:
+ !! __unstableGetContentLockingParent( clientId ),
+ image:
+ mediaId && isSelected
+ ? select( coreStore ).getMedia( mediaId, {
+ context: 'view',
+ } )
+ : null,
+ imageSizes: getSettings()?.imageSizes,
+ };
+ },
+
+ [ isSelected, mediaId, clientId ]
);
const refMediaContainer = useRef();
@@ -213,10 +225,6 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
setAttributes( { verticalAlignment: alignment } );
};
- const imageSizes = useSelect( ( select ) => {
- const settings = select( blockEditorStore ).getSettings();
- return settings?.imageSizes;
- }, [] );
const imageSizeOptions = map(
filter( imageSizes, ( { slug } ) =>
getImageSourceUrlBySizeSlug( image, slug )
@@ -322,24 +330,31 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
<>
{ mediaTextGeneralSettings }
-
- setAttributes( { mediaPosition: 'left' } ) }
- />
-
- setAttributes( { mediaPosition: 'right' } )
- }
- />
+ { ! isContentLocked && (
+ <>
+
+
+ setAttributes( { mediaPosition: 'left' } )
+ }
+ />
+
+ setAttributes( { mediaPosition: 'right' } )
+ }
+ />
+ >
+ ) }
+
{ mediaType === 'image' && (
{ mediaPosition !== 'right' && }
diff --git a/packages/block-library/src/media-text/media-container.js b/packages/block-library/src/media-text/media-container.js
index fb209cff01035..f2bdb475bae34 100644
--- a/packages/block-library/src/media-text/media-container.js
+++ b/packages/block-library/src/media-text/media-container.js
@@ -113,6 +113,7 @@ function MediaContainer( props, ref ) {
mediaWidth,
onSelectMedia,
onWidthChange,
+ isContentLocked,
} = props;
const isTemporaryMedia = ! mediaId && isBlobURL( mediaUrl );
@@ -131,8 +132,8 @@ function MediaContainer( props, ref ) {
commitWidthChange( parseInt( elt.style.width ) );
};
const enablePositions = {
- right: mediaPosition === 'left',
- left: mediaPosition === 'right',
+ right: ! isContentLocked && mediaPosition === 'left',
+ left: ! isContentLocked && mediaPosition === 'right',
};
const backgroundStyles =