Make WordPress Core

Opened 10 years ago

Last modified 6 years ago

#30150 new enhancement

apply_filters( 'image_size_names_choose' ) should be provided a named context

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

Description

It's used in a variety of places, some that you may want to filter and others that you don't. Each instance of apply_filters( 'image_size_names_choose' ) should be passed a named context

Attachments (2)

30150.patch (4.2 KB) - added by realloc 10 years ago.
Using magic constant FUNCTION for context
30150-2.patch (4.3 KB) - added by realloc 10 years ago.
Filter should use explicit context

Download all attachments as: .zip

Change History (10)

@realloc
10 years ago

Using magic constant FUNCTION for context

#1 @realloc
10 years ago

  • Keywords has-patch added; needs-patch removed

#2 follow-up: @SergeyBiryukov
10 years ago

Note that the filter is used three times in the wp_print_media_templates() function.

An explicit context would probably work better than __FUNCTION__, e.g. custom-background, attachment-display-settings, gallery-settings, image-details, etc.

@realloc
10 years ago

Filter should use explicit context

#3 in reply to: ↑ 2 @realloc
10 years ago

Replying to SergeyBiryukov:

An explicit context would probably work better than __FUNCTION__...

Yes, it is probably better to use an explicit context here. Thank you!

This ticket was mentioned in Slack in #core by danielbachhuber. View the logs.


9 years ago

#5 @wonderboymusic
9 years ago

#30198 was marked as a duplicate.

#6 @dnaber-de
9 years ago

In #34981 I documented a performance issue that arise when removing sizes from the filtered array. This patch would help to avoid those problems. Maybe you want to consider another priority than »low«.

#7 @joemcgill
8 years ago

  • Priority changed from low to normal

Worth noting my comment on #34981.

Are there contexts other than wp_prepare_attachment_for_js() where filtering this value is needed? Perhaps we should either move the filter out of wp_prepare_attachment_for_js() and into the views being built from the size data returned by these AJAX requests, or allow a second parameter to be passed to wp_prepare_attachment_for_js() which would return all available sizes.

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


6 years ago

Note: See TracTickets for help on using tickets.