gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Right aligned images that should be on top of eachother are published next to eachother, violations of WYSIWYG

Open mellis32 opened this issue 8 years ago • 1 comments

Issue Overview

I noticed that Gutenberg's handling of images has many issues. One of these issues that is very problematic for my site is the inability to align multiple "stacked" images. Right and left aligned images will not "stack" properly once published. This cannot be achieved properly with galleries either, see #5154.

Once published, "stacked" images just float next to each other rather than on top of eachother.

Steps to Reproduce (for bugs)

  1. Add two image blocks to post.
  2. Align both images to the right.
  3. Notice in post editing that these images are "stacked"on top of eachother if done properly.
  4. Publish post.
  5. Notice in published post that images are next to each other rather than on top of eachother.

Expected Behavior

Published images in this example should be right aligned and on top of eachother as they show in Gutenberg, not next to eachother.

Current Behavior

Screenshot from Gutenberg:

earthworm preview

Screenshot from published post:

earthworm published

Demonstrated here: http://mdinvasives.org/iotm/april-2015/

mellis32 avatar Feb 20 '18 02:02 mellis32

Thank you for the ticket.

We recently (as in yesterday, will be in Gutenberg 2.3) made some changes to how images are floated in Gutenberg.

As far as I can tell, the behavior described here is correct, and the discrepancy is from the fact that the WordPress theme main column on your site fitting both images side by side, whereas the Gutenberg editor theme does not fit them both side by side.

Notably, the Gutenberg editor has a 608px main column. The two images in this post are 300px both. When an image is floated in Gutenberg, it gets a 2em left margin, which makes the element itself roughly 330px in width. As such, the Gutenberg main column can't fit the two side by side, which means the floats will place themselves after each other instead, which is the correct HTML float behavior. Here are the metrics:

screen shot 2018-02-23 at 09 31 31

If I manually make the Gutenberg main column wider, the floats do stack side by side as is shown on your theme screenshot:

screen shot 2018-02-23 at 09 34 36

There is an issue still with Gutenberg applying a max-width to floated images, but I will look at this separately, and this is also partially addressed, as far as I can tell, in #5209.

Long term we hope to load the theme stylesheet itself into Gutenberg. That means you'd see the same on the frontend and backend, and the main column would be wider too. That would let you see the same in both cases.

Closing for now, but feel free to get back with more info if the issue persists.

jasmussen avatar Feb 23 '18 08:02 jasmussen