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

Improve image figure widths, remove inline styles #5973

Merged
merged 4 commits into from
Apr 13, 2018
Merged

Conversation

jasmussen
Copy link
Contributor

As themes try to accommodate the new image figure syntax in Gutenberg, there are increasingly issues with the figure being a block element whereas img traditionally being an inline block. The bigger problem is that when we float things, and an image isn't explicitly resized, we set an inline max-width, which can only be overridden using !important, which you should never ever use.

GIF:

images

As such, this PR removes those inline styles. In a way, it is an almost identical copy to Gary's PR in #5209, which this is meant to replace (apologies, and you should have all the props). My concerns noted in #5209 (comment) are not technically addressed, but in order to move on, these are perhaps best addressed separately.

Notably those issues are specific to floats. Specifically that if we use the float trick in https://codepen.io/joen/pen/oEYVXB to accommodate both floats and wide images in a fairly elegant way (the editor itself uses this also), we essentially need yet another wrapping element. In other words, merging in #5460 would address those concerns — but we have to be okay with adding yet another wrapping element. This is also tracked in #5292

This PR fixes #3945 and #5213. I think it also fixes #5567 by making that core issue moot.

CC: also @aduth and @samikeijonen, as I think you were working on a separate PR that accomplished some of the same as this.


To summarize, what works well with this branch

  • floats
  • wide and fullwide alignments
  • themes can handle floats better, and legacy themes mostly just work (though with some edgecases when captions are added)
  • no need to use !important in themes

What sort of regresses in this branch is that if you insert a huge image, bigger than the main column, and float it, well it doesn't really look like it floats. You have to resize it first. This is because I removed the max-width. This is similar to how it's always worked, though perhaps not as elegant.

Joen Asmussen added 2 commits April 4, 2018 11:24
This fixes #3945 and #5213. It is a new PR that is meant to replace #5209. This PR is a work in progress.
@jasmussen jasmussen self-assigned this Apr 4, 2018
@jasmussen jasmussen requested review from pento and a team April 4, 2018 10:17
@jasmussen
Copy link
Contributor Author

Noting that I'm increasingly leaning towards #5460 being a potential solution. It is not quite as clean, markup wise, but to make it easier to address wide and fullwide styles, perhaps that's okay. We can also look at doing something like is suggested in #5460 (comment), which is to only add that extra markup to floated images if you opt in to wide alignments. Thoughts? CC: @mtias

@noisysocks
Copy link
Member

noisysocks commented Apr 11, 2018

I pulled this and played with inserting image blocks and setting them to have different alignments. Everything there seems to work great, both in the editor and on the front-end! 🎉

The big regression I'm noticing is when you try to align Cover Images, Galleries, Embeds blocks, etc. Some examples:

Block Before After
Cover Image cover image before cover image after
Gallery gallery before gallery after
Embed embed before embed after

@jasmussen
Copy link
Contributor Author

Awesome catch on those blocks, thank you for the review Robert. I will address those.

Affects CoverImage, Gallery, Embed. This moves those styles to each blocks individual stylesheet.
With the presence of `fit-content` applied to the figure, the explicit inline style is no longer required.
@jasmussen
Copy link
Contributor Author

Okay I addressed your feedback, I believe this should be good for another review.

Copy link
Member

@noisysocks noisysocks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@jasmussen jasmussen merged commit 2dc9fb3 into master Apr 13, 2018
@jasmussen jasmussen deleted the fix/image-widths branch April 13, 2018 07:52
@jasmussen jasmussen added this to the 2.7 milestone Apr 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make the max-width for images filterable Right-align small images pinned to top-left of boxblock
2 participants