-
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
Image classes missing in render #11603
Comments
Adding an example of the current HTML from an image block compared to the HTML for the same image in the classic editor for reference:
Tested with WordPress 4.9.8 and Gutenberg 4.3.0-rc.1 using a thumbnail-sized image.
Tested with WordPress 4.9.8 using a thumbnail-sized image. Aside: I noticed a semi-related PR wants to add an @strarsis thank you for asking about this! If you are able to add an example for the situation you mentioned where a specific size that has a special purpose and how the theme would use the classes such as |
@designsimply: Let's have for example a 'portrait' image size. The theme can now make it rounded using |
Why is this tagged as a feature request and an enhancement?? this is a breaking reversion from how images have worked in WordPress for several years. We need parity with the existing classes for theme compatibility. |
@gschoppe used logic reasoning. It's not very effective... |
@gschoppe @bupotalovo sometimes I get a label wrong! A helpful explanation for why it should be changed is always much appreciated!! My original thinking for this case was that the new syntax is intentional and so changing it would be an update to something existing and not something that's broken—however!, I understand that it can be a fine line depending on the case/context and it's very possible for me to get it wrong sometimes. I've swapped out |
Thanks for the reclassification. This may be an intentional decision, but it does remove the ability for front-end scripts and stylesheets to reason about the thumbnail size being used. For an edge case example, my wp-smartcrop plugin needs to apply a custom class to any image in the content that has a specific metakey assigned to the ID and is not a cropped size. The ID part is functional, but I cannot check the image's size class to identify whether we are using a cropped size or not. Another really simple use case would be adding border radius to all images that have the |
@designsimply Thanks for clarification. The Label |
@mtias can we get a little attention to this issue? At the moment, thumbnail-size and image dimensions are not made available to PHP or front-end JS by Gutenberg at all. So filters can't modify the functionality of the image block to provide progressive enhancements. Examples of things that are currently not possible with the lack of data provided to PHP/JS:
Even if this data was just stored in the attributes of the block and not rendered, we could use the render filter to enhance this functionality where needed, but as it is, the context is just lost entirely. |
I'm also struggling with this. Removing the size class attributes makes it impossible to reason about the images included in the document for mobile-first design... I have to treat a 150px thumbnail the same as a 1200px centrepiece. This is a real shame because I really like the Gutenberg interface, but converting classic editor posts to Gutenberg breaks themes. Out of all the class spam within WordPress, I really don't understand why this semantic and genuinely useful information is what's been chosen to be thrown away. |
The most frustrating thing about this is that we can't even patch it in with a block filter, since the block doesn't even know what size was selected in its attributes blob, it just has an ID and a URI, which is not sufficient data to describe the state of the media library. |
This seems pretty important. I'd like to suggest we move forward with it. Shouldn't be too difficult to append a className to the image when rendered. Let's get some dev help on this. 👍 |
I am working on this. |
Hi there is a draft PR #15464 which solves this issue, however it still needs a bit of refactoring :) |
#15464 fixed this. |
Is there any reason why this class can't be duplicated on the actual img tag? Doing so would provide back compatibility with existing code that relies on these size classes. As it is, the functionality exists, but will require a rewrite of any existing code targeting them. |
I don't think there is any limitation not to do it. The way it was implemented was simply because I followed along the current pattern of using the container figure for styling. You could open a separate issue to see if anyone else has valuable input on duplicating or not :) |
Steps to reproduce the behavior:
<img
element nor its wrapper elements have an image size related classes assigned. This is very useful for themes, especially when the theme register its own image sizes that are more special purpose.Expected behavior
That the either the resulting
<img
element or its wrapper elements has the image-size related classes assigned.Desktop (please complete the following information):
Additional context
WordPress 4.9.8
Gutenberg 4.2.0
The text was updated successfully, but these errors were encountered: