gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Image block: Height Settings stays Auto rather than showing pixel numbers when using resize handles

Open vparkhere opened this issue 3 years ago • 4 comments

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

  1. Create/open a post or page.
  2. Add an image block to the editor.
  3. Use the resize handles to change the height or width.
  4. 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

vparkhere avatar Sep 14 '23 18:09 vparkhere

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?

jordesign avatar Sep 19 '23 00:09 jordesign

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!

mrfoxtalbot avatar Sep 19 '23 08:09 mrfoxtalbot

In retesting this again - I've been able to recreate as well, but only with Gutenberg active.

jordesign avatar Sep 19 '23 10:09 jordesign

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
Image Image

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.

BugReportOnWeb avatar Jun 06 '25 13:06 BugReportOnWeb