Skip to content

Commit

Permalink
Revert "Prevent the image from being resized larger than its container (
Browse files Browse the repository at this point in the history
#45775)" (#47846)

This reverts commit 2e8c7e4.
  • Loading branch information
d-alleyne authored Feb 8, 2023
1 parent a1f736b commit 8342d99
Showing 1 changed file with 36 additions and 25 deletions.
61 changes: 36 additions & 25 deletions packages/block-library/src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,30 +124,37 @@ export default function Image( {
},
[ id, isSelected, clientId ]
);
const { canInsertCover, imageEditing, imageSizes, mediaUpload } = useSelect(
( select ) => {
const { getBlockRootClientId, getSettings, canInsertBlockType } =
select( blockEditorStore );

const rootClientId = getBlockRootClientId( clientId );
const settings = Object.fromEntries(
Object.entries( getSettings() ).filter( ( [ key ] ) =>
[ 'imageEditing', 'imageSizes', 'mediaUpload' ].includes(
key
const { canInsertCover, imageEditing, imageSizes, maxWidth, mediaUpload } =
useSelect(
( select ) => {
const {
getBlockRootClientId,
getSettings,
canInsertBlockType,
} = select( blockEditorStore );

const rootClientId = getBlockRootClientId( clientId );
const settings = Object.fromEntries(
Object.entries( getSettings() ).filter( ( [ key ] ) =>
[
'imageEditing',
'imageSizes',
'maxWidth',
'mediaUpload',
].includes( key )
)
)
);
);

return {
...settings,
canInsertCover: canInsertBlockType(
'core/cover',
rootClientId
),
};
},
[ clientId ]
);
return {
...settings,
canInsertCover: canInsertBlockType(
'core/cover',
rootClientId
),
};
},
[ clientId ]
);
const { replaceBlocks, toggleSelection } = useDispatch( blockEditorStore );
const { createErrorNotice, createSuccessNotice } =
useDispatch( noticesStore );
Expand Down Expand Up @@ -548,9 +555,13 @@ export default function Image( {
// With the current implementation of ResizableBox, an image needs an
// explicit pixel value for the max-width. In absence of being able to
// set the content-width, this max-width is currently dictated by the
// vanilla editor style. We'll use the clientWidth here, to prevent the width
// of the image growing larger than the width of the block column.
const maxWidthBuffer = clientWidth;
// vanilla editor style. The following variable adds a buffer to this
// vanilla style, so 3rd party themes have some wiggleroom. This does,
// in most cases, allow you to scale the image beyond the width of the
// main column, though not infinitely.
// @todo It would be good to revisit this once a content-width variable
// becomes available.
const maxWidthBuffer = maxWidth * 2.5;

let showRightHandle = false;
let showLeftHandle = false;
Expand Down

0 comments on commit 8342d99

Please sign in to comment.