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

Image: Address UI for picking thumbnail sizes #1727

Closed
jasmussen opened this issue Jul 5, 2017 · 11 comments · Fixed by #2435
Closed

Image: Address UI for picking thumbnail sizes #1727

jasmussen opened this issue Jul 5, 2017 · 11 comments · Fixed by #2435
Assignees
Labels
Core REST API Task Task for Core REST API efforts [Feature] Media Anything that impacts the experience of managing media [Priority] High Used to indicate top priority items that need quick attention [Type] Enhancement A suggestion for improvement.
Milestone

Comments

@jasmussen
Copy link
Contributor

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:

screen shot 2017-07-05 at 14 09 41

Here's the interface you get when you click the edit button on an image after it's inserted:

screen shot 2017-07-05 at 14 06 29

screen shot 2017-07-05 at 14 09 41

See also #1725.

@jasmussen jasmussen added the [Type] Enhancement A suggestion for improvement. label Jul 5, 2017
@jasmussen jasmussen added this to the Beta 0.8.0 milestone Jul 5, 2017
@mtias mtias modified the milestones: Beta 0.7.0, Beta 0.8.0 Jul 6, 2017
@youknowriad
Copy link
Contributor

I guess we need a REST API here to fetch the defined image sizes?

@youknowriad youknowriad added the Core REST API Task Task for Core REST API efforts label Jul 26, 2017
@youknowriad
Copy link
Contributor

Thinking more about this, we could leverage the settings object (like here #2021) to provide the available sizes.

@joemcgill joemcgill added the [Feature] Media Anything that impacts the experience of managing media label Jul 26, 2017
@joemcgill
Copy link
Member

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.).

@mor10
Copy link
Contributor

mor10 commented Jul 28, 2017

@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:

  • large = 100%
  • medium = 50%
  • small = 25%
  • thumbnail = 15% with hard square crop

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:

  • The size drop-down should just display Full bleed, large, medium, small, thumbnail and any custom size the theme developer chooses. No specification about what the physical size is (this is relatively meaningless for users anyway).
  • WordPress tags the img/figure element with the appropriate class for the selected size and provides default CSS that controls displayed size as fallback in case the theme does not support the feature.
  • If a user decides to manually change the size of the image container, an inline style can be generated to set the new image size.
  • RICG code in the markup reflects the current theme settings, or if missing are based on a standard formula based on percentages of the max content width.

@westonruter
Copy link
Member

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).

@mor10
Copy link
Contributor

mor10 commented Jul 28, 2017

These are two separate yet related issues. WordPress needs to move away from the idea of fixed sized images as well as hard cropping.

@paaljoachim
Copy link
Contributor

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/

@karmatosed karmatosed added [Priority] Low Used to indicate that the issue at hand isn't a top priority to address and can be handled later [Priority] High Used to indicate top priority items that need quick attention and removed [Priority] Low Used to indicate that the issue at hand isn't a top priority to address and can be handled later labels Aug 3, 2017
@mtias
Copy link
Member

mtias commented Aug 4, 2017

For galleries: #1450.

@junaidbhura
Copy link

@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:

  1. The image sizes totally depend on the theme that is currently being used. Decoupling image sizes from the editor would make switching to a new theme really easy
  2. If the image sizes are decoupled from the images, they can be used in a variety of contexts, both in the theme and wherever it is needed (maybe it's consumed elsewhere via the REST API)
  3. Content editors don't need to worry about image sizes. Content editors just need to add in the content, and leave the rest to developers

So for these reasons, I would suggest:

  • Not adding image sizes in the editor. Maybe the images' aspect ratios when adding to the editor are defined in the theme? That way some themes can define that when an image is added to the editor, it's added in X:Y aspect ratio, while another theme would like it to be A:B? This way the back-end could sort of mirror the theme
  • Slowly phase out fixed image sizes
  • Build functionality to dynamically resize images as and where they are needed

Would love to hear your thoughts!

@mor10
Copy link
Contributor

mor10 commented Aug 18, 2017

@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/

@mellis32
Copy link

mellis32 commented Feb 20, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core REST API Task Task for Core REST API efforts [Feature] Media Anything that impacts the experience of managing media [Priority] High Used to indicate top priority items that need quick attention [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants