WordPress.org

Make WordPress Core

Opened 22 months ago

Closed 21 months ago

Last modified 21 months ago

#18520 closed enhancement (fixed)

Allow addition of image sizes in Thickbox via filter

Reported by: alexkingorg Owned by: azaozz
Priority: normal Milestone: 3.3
Component: Media Version: 3.3
Severity: normal Keywords: has-patch
Cc: nacin

Description

Plugins and themes can register new image sizes, but these don't appear in the media lightbox (#15668).

The right thing to do might be to add a param to add_image_size() that tells it if the image size should be included in the media lightbox (because you definitely don't want to auto-add them all). However, this would be a rather invasive change which would alter the data in global $_wp_additional_image_sizes and may introduce bugs.

Perhaps an easier approach is just to add a hook (patch attached).

If there is consensus that an additional parameter to add_image_size() and automatically displaying those sizes in the media lightbox, I can put together a patch for that too.

Attachments (3)

patch.diff (677 bytes) - added by alexkingorg 22 months ago.
Allow image sizes to be filtered into media lightbox.
patch-w-css.diff.zip (47.1 KB) - added by alexkingorg 22 months ago.
Add filter and update CSS to better allow customization
patch-w-css-dev-only.diff (2.5 KB) - added by alexkingorg 22 months ago.
Same patch, but only changing .dev files (much more readable)

Download all attachments as: .zip

Change History (9)

alexkingorg22 months ago

Allow image sizes to be filtered into media lightbox.

comment:1 alexkingorg22 months ago

Once we allow additional sizes to be filtered in, the UI needs a little revision as well. The alignment options need to be moved flush left (to match the rest of the fields) and the different sizes need to be presented in a vertical list instead of floated. Here are screenshots for demonstration purposes:

We trade a touch of vertical hight for the default case to be able to better accomodate customization. A reasonable trade IMO.

I've attached a patch that includes the CSS changes needed for this (along with the filter addition).

alexkingorg22 months ago

Add filter and update CSS to better allow customization

alexkingorg22 months ago

Same patch, but only changing .dev files (much more readable)

comment:2 Otto4222 months ago

At some point, that lightbox starts getting too large. I have no problem with allowing additional sizes in there, but maybe a different UI idea is needed there. What happens when a theme puts in like 15 image sizes (and don't think they won't).

comment:3 azaozz22 months ago

  • Owner set to azaozz
  • Status changed from new to reviewing

Agree that adding a filter on the selectable image sizes seems the better option. We are attempting to change the layout of the Media Library popup and do away with Thickbox but will always need plugins control on the image sizes available for insertion into the post by the user.

@Otto42 yes, I'm sure some plugins will do some crazy things in there, but I've seen crazy things done with the media library popup right now too :)

comment:4 alexkingorg22 months ago

My goal is to allow users to easily use the sizes that the themes/plugins create that will best match their display needs. I'm not trying to favor any specific implementation, this just seemed like the lowest hanging fruit.

Otto, you did see the screenshots where I reconfigured the UI a little to allow for more sizes to be listed in a slightly cleaner way?

Getting rid of the pop-up in favor of a better media integration sounds great to me.

comment:5 azaozz21 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In [18802]:

Add filter so the users can select custom image sizes added by themes and plugins, props alexkingorg, fixes #18520

comment:6 SergeyBiryukov21 months ago

  • Milestone changed from Awaiting Review to 3.3
Note: See TracTickets for help on using tickets.