Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image Block: Don't render DimensionsTool if it is not resizable #53181

Merged
merged 3 commits into from
Aug 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions packages/block-library/src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,24 +477,26 @@ export default function Image( {
/>
</ToolsPanelItem>
) }
<DimensionsTool
value={ { width, height, scale, aspectRatio } }
onChange={ ( newValue ) => {
// Rebuilding the object forces setting `undefined`
// for values that are removed since setAttributes
// doesn't do anything with keys that aren't set.
setAttributes( {
width: newValue.width,
height: newValue.height,
scale: newValue.scale,
aspectRatio: newValue.aspectRatio,
} );
} }
defaultScale="cover"
defaultAspectRatio="auto"
scaleOptions={ scaleOptions }
unitsOptions={ dimensionsUnitsOptions }
/>
{ isResizable && (
<DimensionsTool
value={ { width, height, scale, aspectRatio } }
onChange={ ( newValue ) => {
// Rebuilding the object forces setting `undefined`
// for values that are removed since setAttributes
// doesn't do anything with keys that aren't set.
setAttributes( {
width: newValue.width,
height: newValue.height,
scale: newValue.scale,
aspectRatio: newValue.aspectRatio,
} );
} }
defaultScale="cover"
defaultAspectRatio="auto"
scaleOptions={ scaleOptions }
unitsOptions={ dimensionsUnitsOptions }
/>
) }
<ResolutionTool
value={ sizeSlug }
onChange={ updateImage }
Expand Down
Loading