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 in row block shrinks on front end but not in the editor #68057

Open
3 of 6 tasks
jgvaldez84 opened this issue Dec 17, 2024 · 6 comments · May be fixed by #68430
Open
3 of 6 tasks

Image in row block shrinks on front end but not in the editor #68057

jgvaldez84 opened this issue Dec 17, 2024 · 6 comments · May be fixed by #68430
Labels
[Block] Group Affects the Group Block (and row, stack and grid variants) [Block] Image Affects the Image Block CSS Styling Related to editor and front end styles, CSS-specific issues. [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@jgvaldez84
Copy link

jgvaldez84 commented Dec 17, 2024

Description

In a row block, if an image is resized to a specific width and placed next to a multi-lined paragraph, the image appears small on the front end, but is the correct size in the editor. This is confusing for folks learning how to use the row block for layout because the published page is different from what they expect.

Reproduced in the Twenty Twenty Four theme.

Step-by-step reproduction instructions

  1. Add a row block
  2. Add an image inside and give it a fixed width (300px)
  3. Add a multi-line paragraph next to that image block
  4. Image is 300px wide in the editor but is only 45px wide in the published front end

Screenshots, screen recording, code snippet

No response

Environment info

WP 6.7.1
Gutenberg plugin not active
Tested in both Twenty Twenty Four Theme and custom Hybrid theme
Mac, Chrome

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

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@jgvaldez84 jgvaldez84 added the [Type] Bug An existing feature does not function as intended label Dec 17, 2024
@jgvaldez84 jgvaldez84 changed the title flexbox issue on row image shrink Image in row block shrinks on front end but not in the editor Dec 17, 2024
@Mayank-Tripathi32
Copy link
Contributor

The pixel width is not applied correctly on the frontend. Although it is assigned to the element, it appears to be applied relatively, which may be causing the observed behavior.

Here’s a video showing the issue:
Video Demonstration

@Mayank-Tripathi32
Copy link
Contributor

Mayank-Tripathi32 commented Dec 17, 2024

The pixel width is not applied correctly on the frontend. Although it is assigned to the element, it appears to be applied relatively, which may be causing the observed behavior.

Here’s a video showing the issue: Video Demonstration

I think its related to image block itself, as if you add an image with width 1020px, it should overflow on mobile but it doesn't.

Tried with: WP 6.6.2 & 2024 theme

@Mayank-Tripathi32
Copy link
Contributor

Image
Seems to be due to max-width being applied to image, I think we should have a toggle for this?

@andreawetzel
Copy link

It seems that in the editor, the width is set to the <div> that holds the image then in the published page, the width is applied to the <img> itself

Screenshot of div with a width value on the editor

Image

Perhaps on the front end the Image Width could be applied to the <figure> element and also give it a flex-shrink:0 to prevent this size from changing?

Screenshot where size and flex-shrink values have been added to figure element on front end to prevent the image from shrinking

Image

@Mayank-Tripathi32
Copy link
Contributor

@andreawetzel Based on my research into previous issues, adding width and height attributes in figure element appears to have been an intentional change related to captions. It might be worth exploring this further to identify a potential fix using max-width application.

Reference: PR #53274

@ellatrix ellatrix added CSS Styling Related to editor and front end styles, CSS-specific issues. [Block] Image Affects the Image Block [Block] Group Affects the Group Block (and row, stack and grid variants) labels Dec 19, 2024
@ellatrix
Copy link
Member

I can reproduce, and both removing the max-width: 100% and a wrapper div work. I don't think we should add the div on the front-end though. Not sure what the right solution is here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Group Affects the Group Block (and row, stack and grid variants) [Block] Image Affects the Image Block CSS Styling Related to editor and front end styles, CSS-specific issues. [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants