Make WordPress Core

Opened 6 years ago

Last modified 2 years ago

#44441 accepted enhancement

Remove the settings for image dimensions from Settings => Media

Reported by: azaozz's profile azaozz Owned by: joedolson's profile joedolson
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch
Focuses: Cc:

Description (last modified by azaozz)

WordPress has been using the srcset and sizes img tag attributes for quite a while now. These attributes were somewhat "new" several years ago, but are now "mainstream". When they are present the browsers disregard the src attribute and instead use only the srcset attribute.

This generally means that when creating a post the users are no longer constrained by having to choose a specific image size (that has to exist). The users can add pretty much any size images, only constrained by the theme's width. Then the browser will choose the proper image file to download for the specific case/device for each visitor to the site.

In that terms the ability to change the default image sizes "by hand" is no longer appropriate. These sub-sizes are used to support the list of available images in the srcset attributes. They are not useful as restrain when creating a post and inserting an image. Having the max width and max height settings for them on the Settings => Media screen doesn't make sense.

Attachments (1)

44441.diff (7.1 KB) - added by johnregan3 3 years ago.
Intial patch

Download all attachments as: .zip

Change History (35)

#1 follow-up: @joyously
6 years ago

Since they have been there awhile now, they are used for many other things. So removing them now would impact more than just the narrow scope you have mentioned.
I just submitted a theme that uses the existing images sizes in a list for the user to choose which one he wants for a theme option. I'm sure I'm not the only one. There are probably a lot of themes and plugins that use these image sizes.

#2 in reply to: ↑ 1 @azaozz
6 years ago

Replying to joyously:

Since they have been there awhile now, they are used for many other things. So removing them now...

Uh, sorry, seems I didn't explain it well and you misunderstood :)

I'm not proposing to remove the image sizes. They are needed to be able to create proper srcset. In fact I think we would need to add another, larger size.

What I'm proposing is to remove the settings for the medium and large sizes from the "Settings => Media" screen as changing them "by hand" doesn't make sense any more. In fact there is already another default size: medium_large, 768px width, that is not shown there :)

Wondering if themes and plugins should still be able to change these sizes (for now), although that doesn't make much sense either.

This will improve the creation of the srcset attribute as we will have a number of reliable, uniform sizes created for each image, so the browser will have more alternatives when picking which image file to download on the front-end.

Last edited 6 years ago by azaozz (previous) (diff)

#3 @azaozz
6 years ago

  • Description modified (diff)

#4 @azaozz
6 years ago

Thinking more about this, we will probably also need to list what sizes are currently being created and a "Reset to default" button on the Settings => Media screen.

Plugins and themes can change the options, and even after deactivating a plugin or switching to another theme the changes remain. The users should be able to reset that.

#5 follow-up: @joyously
6 years ago

Uh, sorry, seems I didn't explain it well and you misunderstood :)

No, I don't think I misunderstood. I'm saying that the user should be able to choose the sizes manually. My theme (and perhaps others) defines the content_width by what the user has already chosen for Large width, since that is what all the images already are sized to. The user knows what his site will need, and what size his images will likely be. WordPress does not.

See this recent forum post: https://wordpress.org/support/topic/resized-images-much-bigger-than-original-ones/

I have never understood why the sizes need to be generated on upload (and mostly never used) when they could easily be served as needed, like in the Dynamic Image Sizes plugin.

#6 in reply to: ↑ 5 @azaozz
6 years ago

Replying to joyously:

No, I don't think I misunderstood. I'm saying that the user should be able to choose the sizes manually.

Two things:

  • All current sizes will still be created and be available for the user to choose. This ticket is about reducing pointless options (clutter) on the Settings => Media screen.
  • When using srcset the image size that is selected by the user does not matter. Example: if the user selects "large" size, the browser may download the "medium" size instead if the width of the displayed image is small. The image src attribute is not used by the browser. The srcset is used instead.

I have never understood why the sizes need to be generated on upload (and mostly never used) when they could easily be served as needed, like in the Dynamic Image Sizes plugin.

Unfortunately this is not as easily done as it appears. Depends on the hosting account. I believe there are few (old) tickets for that.

#7 follow-up: @joyously
6 years ago

All current sizes will still be created and be available for the user to choose. This ticket is about reducing pointless options (clutter) on the Settings => Media screen.

The options are not pointless. They let the user choose what size the medium and large is. And then themes like mine use those numbers to set the content_width, which drives the rest of the srcset calculations.

When using srcset the image size that is selected by the user does not matter.

Ah, but that is only if nothing is filtering out the srcset. It is optional, you know. And themes do change what is output, including removing it completely. And you are talking about the user choosing a size for an image in a post. But there are lots of other places where those sizes can be used, and the user should still be able to set them, as they can now.

#8 in reply to: ↑ 7 @azaozz
6 years ago

Replying to joyously:

They let the user choose what size the medium and large is. And then themes like mine use those numbers to set the content_width, which drives the rest of the srcset calculations.

Hmm, not sure it is such a good idea to base the theme's content_width on the image width. But then it is even worse if the user changes these image sizes. User case:

  • The user installs a theme what gets the width from the image width.
  • The user changes the image width to suit their taste, lets say 600px.
  • In two weeks the user changes their mind and sets the width to 1000px.
  • In another two weeks they change it again to 500px.

What happens with the images and the posts that were published during all these changes? And what happens when the user switches themes? They are stuck with some non-standard images in their older posts...

I mean, as long as there are settings, the users can keep changing them, randomly. How do you support that? :)

When using srcset the image size that is selected by the user does not matter.

Ah, but that is only if nothing is filtering out the srcset. It is optional, you know.

Right. It is optional, but is also a "best practice". Of course themes can decide to mangle it or drop it, but they will be "doing-it-wrong".

...there are lots of other places where those sizes can be used, and the user should still be able to set them, as they can now.

Could you give some examples where images will not benefit from having srcset (i.e. are not used on the front-end or in a web browser), and the usage would benefit of having a particular default WordPress size changed? I mean, if a plugin or a theme is adding some specific use of images, like some of the default themes, it should probably add a custom image size for that specific purpose?

#9 follow-up: @joyously
6 years ago

What happens with the images and the posts that were published during all these changes? And what happens when the user switches themes? They are stuck with some non-standard images in their older posts...

Nothing new. This has ever been the situation. At least my theme uses what the user has already chosen instead of introducing a new set of image sizes.

Right. It is optional, but is also a "best practice". Of course themes can decide to mangle it or drop it, but they will be "doing-it-wrong".

It's not necessarily "wrong" if it gives the user what he wanted.

Could you give some examples where images will not benefit from having srcset

I'm not sure I'm following your train of thought here. It's almost as if you are thinking that the Media size options are only used for srcset and therefore we should get rid of them. I'm saying that they could be used for other things that you don't know about, and it does not hurt anything to leave them alone.

#10 in reply to: ↑ 9 @azaozz
6 years ago

Replying to joyously:

Nothing new. This has ever been the situation.

Hm, so we should never try to improve that "situation"? :)

It's not necessarily "wrong" if it gives the user what he wanted.

Well, it is quite outdated approach and not "best practice". The users may want to use tables for layout, and they certainly can if they wanted. But it... sucks and makes their sites look really bad :)

I'm not sure I'm following your train of thought here. It's almost as if you are thinking that the Media size options are only used for srcset and therefore we should get rid of them.

Yes, for the last couple of years the image sub-sizes created after uploading an image are primarily used to populate the srcset attribute of the <img> on the front-end. Using a particular size in the editor does not limit the browser to that size like it was with the old src attribute.

I'm saying that they could be used for other things that you don't know about

Right. That's what I was asking above. Could you describe an user case where a particular, hard-coded image size (that is different from the WordPress default) is needed? That user case should allow for the user to change that image size at will, randomly, because this is how these settings work at the moment.

This ticket was mentioned in Slack in #core-media by desrosj. View the logs.


6 years ago

#12 @kirasong
6 years ago

Thanks for raising these concerns @joyously!

I'd love to know more about examples of the ways folks are currently using these settings to make sure whatever is next takes that into account.

#13 @karmatosed
6 years ago

I would really like to see these removed. In saying that I absolutely understand all fallbacks and a solid route needs to be worked out, it's something needs assessing but it is something needs doing. I totally agree we need to know the stress cases for this to plan.

A few additional aspects include making sure there's time for this change, education and training materials will need to change for users.

Ultimately though many users don't get what these sizes mean, it's a complication we don't need so let's work out how we as smoothly as possible remove these.

#14 @joemcgill
6 years ago

I also agree that it would be good for us to move away from exposing options for managing a subset of default image resizing settings in the admin menu. These settings were originally added over 10 years ago 😱 in [6952] as a way for site owners to control the display width of images in posts, before WordPress was doing any image resizing of files on upload.

A lot has changed over this amount of time and site owners should no longer need to depend on these options to control the display size of the images on their site. Instead, these options should be set by themes so WordPress knows explicitly how to generate image sizes that are optimized for the display needs of the theme. Ideally, site owners shouldn't need to be concerned with the dimensions of images WordPress is generating for them and instead be given tools to control the intended display (e.g., layout, crops, etc.) for those images and let WordPress (or integrated tools) manage the complexity of generating the appropriate image sizes.

In the spirit of decisions, not options, removing these from the admin reduce the potential for user confusion and mistakes, and gives WP core, theme, and plugin developers a more consistent set of expectations from which to build smarter multimedia optimizations and user experiences.

All that said, after 10 years there are a lot of legacy expectations that we need to be aware of so we can make an informed decision about how to remove this feature. It would be good to collect use cases for how the ability to control these options from the admin are being used so we can evaluate any backwards compatibility concerns we might have missed.

#15 @joyously
6 years ago

You can start finding the uses by running a search for some of the functions in the plugin and theme repos.

#16 @joyously
6 years ago

This related ticket just arrived (wanting more options)

Images: Option to control when to create different image dimensions

#44542

#17 @rogerlos
6 years ago

If we're wish-listing how WP could better handle the administration of images and their many-and-varied sizes, here's my experience implementing 100 custom themes for various clients, both designed by me or designed by someone else:

  • Hardly anyone whose job it is to administer web sites cares about actual pixel dimensions
  • Nearly everyone cares about image aspect ratios...and in adaptive layouts, the desired aspect ratio may be different for different device widths
  • It's incomprehensible for your average site admin (I have heard this dozens of times) that changing a theme or changing the image size means having to install a plugin to "regenerate thumbnails" for their existing image library if they want to see the new size
  • Wordpress does have some inconsistent behaviors surrounding images, especially if the user has used the editor to alter the original uploaded image. (I lodged a bug which never got any traction noting that if a user edits an image in such a way that it's now smaller than a defined size, WordPress silently uses the unaltered image instead if the large size is called for.)

I think it's smart for WordPress to silently, based on stats/best practices/whatever to define some image sizes to be used by srcset. When a theme or a plugin defines a size, they should be defining the aspect ratio. (And if they don't care about the aspect ratio, they don't need to define a size at all.)

Really, rules about max sizes (like "left-aligned images in the body should never be more than half the width of the content box") should be defined with CSS rules in any case.

This would mean WP could be smart about thumbnail creation...if my plugin creates dorky_plugin_wide => [ 16, 9 ] and the theme creates theme_content => [ 16, 9 ], WordPress only needs to go get its set of myimage-16-9-{width}.jpg images.

(Out of the box, WP could ship with 16:9, 4:3 and square. That covers nearly every use case for some very large percentage of sites, eh?)

#18 @pento
6 years ago

  • Milestone changed from 5.0 to 5.1

This ticket was mentioned in Slack in #core-media by mike. View the logs.


6 years ago

#20 @kirasong
6 years ago

  • Milestone changed from 5.1 to Future Release
  • Type changed from defect (bug) to enhancement

Changing the type to enhancement, because this is a change to settings rather than a bug, and punting because we're already in beta.

I personally think this is worth doing, but should happen in alpha.

#21 @theMikeD
5 years ago

Everything @rogerlos said. There are much more serious and bigger fish to fry with how images are handled than this. Like maybe removing the hardcoded HTML for embedded images and using a shortcode instead, like the gallery does. This way, when WP determines, a given specific image can be deleted without potentially causing an image 404 because that specific image was hardcoded into content somewhere.

#22 @azaozz
4 years ago

  • Description modified (diff)
  • Milestone changed from Future Release to 5.9
  • Summary changed from Remove the settings for "medium" and "large" image sizes from Settings => Media to Remove the settings for image dimensions from Settings => Media

#23 @azaozz
4 years ago

Based on the discussion here, and after a quick chat with @hellofromTonya, thinking it would be quite nice to try to do this in 5.9.

The reasoning is that:

  • It' is no longer a good idea to let the users change the image sub-sizes settings. That was necessary years ago (before srcset) when having an image file with the exact dimensions was considered best practice.
  • It will be beneficial for core and for themes and plugins to be able to rely on always having specific image sub-sizes. Currently a used could set a thumbnail to be larger than a "medium" or even a "large" size.
  • Custom image sub-sizes are commonly added (defined) in themes and plugins. Then these sizes are "expected" and used. There seem to be very few cases where a custom size added by the user would be useful.

The idea is to remove the settings for the default image sub-sizes. Then eventually add an "Add a custom image size" button with some help and explanations that it's not really a good idea to have that.

For back-compat, if any of the settings have been changed the UI for them should still be shown and the users should be advised to reset them to the default values.

This ticket was mentioned in Slack in #forums by joyously. View the logs.


4 years ago

#25 follow-up: @joyously
4 years ago

It seems like there are many years worth of sites (40% of internet?) that have these image settings. How would you test to make sure all those don't break? You can't look only at the core usage of the options.
It looks like at least 700 plugins reference medium_size_w https://wpdirectory.net/search/01F751TVB5E6Q73MXYS2QD08M8
and 50 themes also https://wpdirectory.net/search/01F7528VA2NS2T6CVK6FXBTV34
(that excludes themes like mine that build the option name dynamically)

#26 in reply to: ↑ 25 @azaozz
4 years ago

Replying to joyously:

It seems like there are many years worth of sites (40% of internet?) that have these image settings. How would you test to make sure all those don't break?

Removing/hiding the UI will not disable or change the sub-sizes. Plan is to disable the UI only when these settings haven't been changed. If any of them has been changed, the settings for it would be shown together with a short explanation why this is a bad idea, and a reset button.

Then if the user chooses to reset them, the UI will be hidden and an "Add custom image size" button will be shown (possibly, TBD).

It looks like at least 700 plugins reference medium_size_w...

Right. Plugins and themes will still be able to update these options. Also thinking the users should still be able to override these updates, same as now.

This ticket was mentioned in Slack in #core-media by antpb. View the logs.


3 years ago

#28 @antpb
3 years ago

  • Keywords needs-patch added

Removing/hiding the UI will not disable or change the sub-sizes. Plan is to disable the UI only when these settings haven't been changed.

This seems a safe path forward. Is there anything that can use help here to bring this to life in 5.9?

This ticket was mentioned in Slack in #core-media by antpb. View the logs.


3 years ago

#30 @antpb
3 years ago

  • Milestone changed from 5.9 to Future Release

This was mentioned in review of 5.9 Media tickets ahead of our November 9 deadline. If anyone feels that this can be followed up on before then, please feel free to move it back in the milestone.

@johnregan3
3 years ago

Intial patch

#31 @johnregan3
3 years ago

Initial patch added, including a filter to allow devs to override if these settings should be hidden. May need help with naming, as well as file placement of wp_media_options_should_display_image_size_settings() function.

Note that this also preserves do_settings_fields( 'media', 'default' ); on the Media options page.

This ticket was mentioned in PR #2098 on WordPress/wordpress-develop by johnregan3.


3 years ago
#32

  • Keywords has-patch added; needs-patch removed

Removes admin Media Image size settings. Includes new filter to allow devs to override this feature and display the settings.

Trac ticket: https://core.trac.wordpress.org/ticket/44441

#33 @joedolson
2 years ago

  • Owner set to joedolson
  • Status changed from new to accepted

#34 @azaozz
2 years ago

@johnregan3 Thanks for the patch! It is a good start but I imagined the UI to remove/reset the custom image sub-sizes to be a bit more.

Thinking the "Reset the custom image sizes" UI should start with a nice, longer explanation why these sizes are not useful any more. Mention that:

  • All browsers now use srcset and determine the appropriate image size automatically for the device and screen size of the website visitor.
  • Themes and plugins will work better on different devices with the default image sizes, not unexpected sizes.

Probably expand a little on these points, etc.

Then it should list only the sizes that have been changed (and maybe show the defaults?). Perhaps something like:

 Thumbnail: default size 150x150 pixels, current size: 238x462 pixels.
 Medium:    default size 300x200 pixels, current size: 1280x720 pixels.
 
 [Reset to default sizes]

Also, a bit on-the-fence whether this settings screen should include a way for the user to set a custom image size (only one is enough imho). This can be treated as UI back-compat, and may be useful in some cases, but perhaps would be better to be added by a simple canonical plugin (see https://make.wordpress.org/core/2022/09/11/canonical-plugins-revisited/). Such plugin can also list all currently defined sizes (just list, not allow editing). More opinions/use cases/ideas welcome :)

Note: See TracTickets for help on using tickets.