[wp-trac] [WordPress Trac] #34981: Usage of `image_size_names_choose` breaks JS attachment model attributes

WordPress Trac noreply at wordpress.org
Sat Sep 3 16:05:17 UTC 2016


#34981: Usage of `image_size_names_choose` breaks JS attachment model attributes
------------------------------------+--------------------
 Reporter:  dnaber-de               |       Owner:
     Type:  defect (bug)            |      Status:  new
 Priority:  normal                  |   Milestone:  4.7
Component:  Media                   |     Version:  4.3.1
 Severity:  normal                  |  Resolution:
 Keywords:  needs-docs needs-patch  |     Focuses:
------------------------------------+--------------------

Comment (by joemcgill):

 I don't think that removing the `image_size_names_choose` filter would
 reintroduce #22598 as the main issue there is that people might be using
 the `image_downsize` filter to short circuit WP's native image resizing
 implementation.

 Besides `wp_prepare_attachment_for_js()`, the `image_size_names_choose`
 filter is applied in three other places:

 * `image_size_input_fields()` – only called from legacy media upload
 forms.
 * `Custom_Background::wp_set_background_image()` – deprecated in 3.5
 * `wp_print_media_templates()` – three times, and always used to populate
 size options for a select element.

 If `wp_prepare_attachment_for_js()` is going to continue to be used as a
 standard way to create generalized attachment models to return in AJAX
 requests, then we should probably consider moving this filter to the
 front-end where interfaces are being populated by size options, rather
 than doing so when the model is built.

 If that approach turns out to be impossible due to backwards compatibility
 issues, it might be better pass a second parameter to
 `wp_prepare_attachment_for_js()` which would give requests an opportunity
 to bypass this filter and return all available image sizes.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34981#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list