Skip to content

Commit

Permalink
Image Block: Don't render DimensionsTool if it is not resizable (#5…
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano authored and tellthemachines committed Aug 31, 2023
1 parent 3a9178a commit d564a13
Showing 1 changed file with 20 additions and 18 deletions.
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

0 comments on commit d564a13

Please sign in to comment.