Right now you are inserting full images. We should leverage the option to pick a thumbnail size.
Does this live in the inspector? Or is it a step you go through when you insert the image?
Here's the UI from the old editor:
Here's the interface you get when you click the edit button on an image after it's inserted:
See also #1725.
I guess we need a REST API here to fetch the defined image sizes?
Thinking more about this, we could leverage the settings object (like here https://github.com/WordPress/gutenberg/pull/2021) to provide the available sizes.
I think we have an opportunity to totally rethink the use of the thumbnail size dropdown here. Remember, before WordPress supported responsive images, authors could assume that the image size they selected from the media modal had a 1:1 relationship with an actual image file (and its display dimensions). However, with support for srcset
, an author might select a medium sized image and the browser might request a whichever file was most appropriate based on the viewport width and display density.
I'd like to decouple the display size/alignment of an image in the editor from the file size being inserted so that an author only needs to think about the intended layout, and WordPress handles selecting the right image to display using responsive images.
Morten Rand-Hendriksen really helped to clarify this idea for me while we were working on responsive images, and here's an article he wrote about it at the time.
What I would suggest, for now, is that we support srcset
and sizes
in the editor instead. If a step in the inspector is needed, it should be for authors to select a crop/dimention size (e.g., 1:1 square, 4:3 rectangle, 16:9, etc.).
@joemcgill is 100% on the mark here. The old paradigm of adding fixed-sized images to posts and then shoehorn responsive images code on top makes no sense in a responsive images universe. The whole idea of responsive images is to allow the browser to figure out what image file to load based on various criteria. What WordPress should do is provide a container sized using CSS and tell the browser to pour whatever is the appropriate image file into that container.
From my perspective, rather than define what pixel size a specific image size is, WordPress should define relative sizes based on the post content width:
Full bleed would be something like 100% + whatever padding/margin/grid-column/other thing that restricts the width of regular content.
Theme/plugin developers are then given tools to define additional sizes and redefine the existing ones, not by physical image size but by container size relative to the content area.
This doesn't technically work against how WordPress handles things now, it's just a different way of approaching the same problem: The current modality of having WordPress generate a series of predefined image sizes would stay in place. What would change is theme developers would not need to provide lists of custom image sizes to be regenerated as long as they don't need cropping. Instead, the default image sizes generated by WordPress would usually suffice to meet the needs of most displays, thus reducing the volume of images generated without impacting actual use.
Another major bonus to this approach is responsive images would work properly even for themes that do not have any level of support for this feature. Currently for a theme to leverage responsive images support for performance, a huge pile of code needs to be added. This would go away if WordPress started treating images as responsive images rather than fixed size elements.
To sum up:
In a responsive world, I think the new question to ask is not which image _size_ but which image _crop_. Different theme-defined image sizes potentially get different predefined crops, and one of these crops may be desired for a given use (e.g. head shot vs body shot). In an ideal world, you'd be able to crop any full size image at the time of selection and have the crops dynamically apply without creating a new copy of the image in the media library (see also #21819).
These are two separate yet related issues. WordPress needs to move away from the idea of fixed sized images as well as hard cropping.
Is there a way to skip having 5-6 or more hard coded duplicates of each image? And instead having one image that has a base for the various responsive images? Having a thumbnail to be less kb then the largest image. Something like this I believe: http://image.intervention.io/
For galleries: #1450.
@joemcgill @mor10 I think moving the logic of image sizes and their corresponsing srcset
and sizes
to the theme rather than in the editor would make a lot of sense for the following reasons:
So for these reasons, I would suggest:
Would love to hear your thoughts!
@junaidbhura This is pretty much exactly what I propose in my article and the corresponding Trac ticket.
http://mor10.com/wordpress-image-handling-in-a-responsive-images-world/
Why was this issue closed without allowing a 'custom' option in the in Gutenberg image scaling dropdown?
As far as I can tell the only way to scale the image precisely is to edit the Media file directly? Frustrating.
Most helpful comment
I think we have an opportunity to totally rethink the use of the thumbnail size dropdown here. Remember, before WordPress supported responsive images, authors could assume that the image size they selected from the media modal had a 1:1 relationship with an actual image file (and its display dimensions). However, with support for
srcset
, an author might select a medium sized image and the browser might request a whichever file was most appropriate based on the viewport width and display density.I'd like to decouple the display size/alignment of an image in the editor from the file size being inserted so that an author only needs to think about the intended layout, and WordPress handles selecting the right image to display using responsive images.
Morten Rand-Hendriksen really helped to clarify this idea for me while we were working on responsive images, and here's an article he wrote about it at the time.
What I would suggest, for now, is that we support
srcset
andsizes
in the editor instead. If a step in the inspector is needed, it should be for authors to select a crop/dimention size (e.g., 1:1 square, 4:3 rectangle, 16:9, etc.).