-
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
Output width and height attributes for Image blocks #9421
Conversation
Before, images only had a width or height if the user edited the <input> elements for those, or clicked a percentage pillbox. This sets the width and height on adding an image, and on selecting from the 'Image Size' select element. It keeps the behavior of the class: This only applied on editing the width or height <input>, or on clicking a percentage pillbox.
It looks like the Travis build failed, but that might not be caused by this PR's changes. Does someone have permissions to click 'Restart build'? |
There was a failed build, based on errors that might not have been related to this PR.
@kienstra I restarted the test. The test snapshots with image blocks have no height and width attributes like in your code, so they fail. |
Thanks, @Soean! I'll work on that now. |
The build failed, with an error at test/e2e/specs/adding-blocks.test.js So begin to address this.
There were conflicts in 4 files Resolve those, mainly retaining the master branch changes.
According to the documentation, you're not supposed to edit these files directly.
The e2e tests failed, so update these.
There was a failing test for this, and it doesn't seem meanignful to have "" values for these.
Question About PR Hi @joemcgill, Could you use this PR for #6652, and if so, would you be available to review it? Thanks! |
- core__image__attachment-link.json - core__image__center-caption.json - core__image__custom-link.json - core__image__media-link.json
Any plans on merging this any time soon? |
If you would like to merge this, please ping me here and I'll resolve the merge conflicts. |
@kienstra I see this was closed. It seems to me that it's a rather important enhancement, as most if not all of the lazyload plugins rely on this to avoid jumps. There seem to be no clean workaround at the moment. Why was it closed :( ? Can it be planned for a future update ? As a side note, inline images should also have these height/width attributes. |
Hi @AdrienPerinot, I closed it because it wasn't reviewed. But if someone would like to review it, I'd be glad to update it and resolve the merge conflicts. |
I see - wish it was reviewed as it is a must have in my opinion. |
Thanks! Maybe contacting core Gutenberg contributor(s) would help. |
Description
Could you use this PR for #6652, which ensures that most Image block
<img>
elements will have awidth
andheight
?Before, Image blocks usually only had
width
orheight
attributes for the<img>
if the user edited the<input>
elements for those, or clicked a percentage pillbox:This PR sets the
width
andheight
on selecting an image from the Media Library, and on selecting from the 'Image Size'<select>
element. Clicking a percentage pillbox, like25%
, still updates thewidth
andheight
:The is-resized class
Before, there was an
is-resized
class that applied only when there were width or height attribute values. These values only existed on editing the Width and Height TextControls directly, or from clicking the percentage pillbox (shown in the first screenshot above).But now, there are almost always
width
andheight
values, as they're added via the Media Library, and updated as shown in the second screenshot above.So this adds the attribute isResized to apply the class
is-resized
in the same cases where it was applied before.How has this been tested?
width
andheight
attributes, but nois-resized
classThumbnail
as shown in the second screenshot above.width
andheight
are changed to150
, and there is nois-resized
class:75%
pillbox, as shown in the first two screenshots.width
andheight
are correct, and theis-resized
class is present:Tested on Chrome Version 68.0.3440.106 (Official Build) (64-bit)
Screenshots
Before:
After:
Types of changes
New feature (non-breaking change which adds functionality)
Checklist: