Image block: Height Settings stays Auto rather than showing pixel numbers when using resize handles
Description
What I expected
The text Auto in the image's Height box to change when resizing an image from an image block using the resize handles.
What happened instead
Only the width box showed the resized pixels, height continued to show Auto.
Step-by-step reproduction instructions
- Create/open a post or page.
- Add an image block to the editor.
- Use the resize handles to change the height or width.
- Observe the width and height settings for the block.
Screenshots, screen recording, code snippet
https://github.com/WordPress/gutenberg/assets/11635760/aed12c3c-97ac-4dcc-8ebf-1fd59611eebf
Environment info
WordPress 6.3 Gutenberg 16.5 Themes tested: Blank Canvas, Storefront
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
Hey @vparkhere so far I'm unable to recreate this one on a fresh install with TwentyTwentyThree, without or without Gutenberg installed.
Are you able to test with TwentyTwentyThree and see if you still have the same issue?
I can reproduce this using
WordPress 6.3.1 Gutenberg 16.6 Twenty Twenty-Three
https://github.com/WordPress/gutenberg/assets/4452464/a59a4724-3ffb-4848-b368-2d2d29278dcc
That being said, I am not sure I understand why this is a problem. What would you expect to happen instead and what would be the advantages in that alternative scenario, @vparkhere?
Thank you!
In retesting this again - I've been able to recreate as well, but only with Gutenberg active.
The current use of height: auto seems to be intentional, as it helps preserve the original aspect ratio of the image. This ensures that the image remains responsive and scales naturally across different viewports without distortion.
https://github.com/WordPress/gutenberg/blob/ce2dd7d80c58237c76d6899ecc7f6dea39409bf6/packages/block-library/src/image/image.js#L1071-L1082
Changing the behavior to explicitly set the height in pixels could disrupt the responsive flow when resizing images. Here's a comparison showing how the aspect ratio differs between both approaches on a smaller viewport (375px) and same image width:
| Auto Height | Custom Height |
|---|---|
That said, I'd be happy to open a PR if there's a broader use case for showing the pixel height in the editor UI, or if that's the expected behaviour when resizing images.