WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 10 months ago

#18520 closed enhancement (fixed)

Allow addition of image sizes in Thickbox via filter

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

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 9 years ago.
Allow image sizes to be filtered into media lightbox.
patch-w-css.diff.zip (47.1 KB) - added by alexkingorg 9 years ago.
Add filter and update CSS to better allow customization
patch-w-css-dev-only.diff (2.5 KB) - added by alexkingorg 9 years ago.
Same patch, but only changing .dev files (much more readable)

Download all attachments as: .zip

Change History (10)

@alexkingorg
9 years ago

Allow image sizes to be filtered into media lightbox.

#1 @alexkingorg
9 years 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).

@alexkingorg
9 years ago

Add filter and update CSS to better allow customization

@alexkingorg
9 years ago

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

#2 @Otto42
9 years 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).

#3 @azaozz
9 years 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 :)

#4 @alexkingorg
9 years 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.

#5 @azaozz
9 years 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

#6 @SergeyBiryukov
9 years ago

  • Milestone changed from Awaiting Review to 3.3

This ticket was mentioned in Slack in #core-editor by wingo5315. View the logs.


10 months ago

Note: See TracTickets for help on using tickets.