Skip to content

Commit

Permalink
Use selected media size from setting
Browse files Browse the repository at this point in the history
  • Loading branch information
akasunil committed Dec 6, 2024
1 parent 91dd5e1 commit 2cc9a63
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/block-library/src/media-text/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ function MediaTextEdit( {
allowedBlocks,
useFeaturedImage,
} = attributes;
const mediaSizeSlug = attributes.mediaSizeSlug || DEFAULT_MEDIA_SIZE_SLUG;
const { getSettings } = useSelect( blockEditorStore );
const { imageDefaultSize } = getSettings();
const mediaSizeSlug =
attributes.mediaSizeSlug || imageDefaultSize || DEFAULT_MEDIA_SIZE_SLUG;

const [ featuredImage ] = useEntityProp(
'postType',
Expand Down Expand Up @@ -200,7 +203,6 @@ function MediaTextEdit( {

const { imageSizes, image } = useSelect(
( select ) => {
const { getSettings } = select( blockEditorStore );
return {
image:
mediaId && isSelected
Expand All @@ -223,7 +225,10 @@ function MediaTextEdit( {

const [ temporaryMediaWidth, setTemporaryMediaWidth ] = useState( null );

const onSelectMedia = attributesFromMedia( { attributes, setAttributes } );
const onSelectMedia = attributesFromMedia( {
attributes: { ...attributes, mediaSizeSlug },
setAttributes,
} );

const onSetHref = ( props ) => {
setAttributes( props );
Expand Down

0 comments on commit 2cc9a63

Please sign in to comment.