-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[Block] Image - Resized images maintain a fixed height on small screens, distorting image or adding margins #52739
Comments
Trying this on a different example, the element had the following styles: {
width: 545px;
height: 472px;
} But Gutenberg also adds the following: .wp-block-image img {
box-sizing: border-box;
height: auto;
max-width: 100%;
vertical-align: bottom;
} This means that when |
The only solution I see here (other than the {
width: 545px;
height: 472px;
} the element styles should be: {
width: 545px;
height: auto;
aspect-ratio: 545 / 472;
} This will account for the use-case where the aspect ratio is intentionally changed (i.e. when the user intentionally stretched the image in the editor), and will preserve that aspect ratio regardless of whether the preferred width or the max width gets used. |
@ajlende I see you're working on some image block fixes. Mind taking a look here? |
Thanks for the ping. This is another side-effect of #52286 it seems. I'll try to take a look this week. |
Description
When an image block is resized and the user does not choose a scaling behavior, the image is stretched (compressed) on mobile devices, retaining it's original height while reducing it's width to fit the screen.
If the user chooses the Scale option to
contain
the image size, there are large white margins added above and below the image on small devices in order to retain the same height.Step-by-step reproduction instructions
Contain
under SCALEScreenshots, screen recording, code snippet
Screen.Capture.on.2023-07-18.at.09-45-47.mp4
No Scale Set
"Contain" Scale Set
Environment info
Originally reported here: Automattic/wp-calypso#79533
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
The text was updated successfully, but these errors were encountered: