[wp-trac] [WordPress Trac] #64948: Media Modal: Can no longer set attachment filters

WordPress Trac noreply at wordpress.org
Wed Mar 25 14:09:48 UTC 2026


#64948: Media Modal: Can no longer set attachment filters
-----------------------------+--------------------
 Reporter:  Bernhard Reiter  |      Owner:  (none)
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  7.0
Component:  Media            |    Version:  trunk
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+--------------------
 I have a plugin which modifies the media library modal by removing some of
 the attachment filters. It does so by getting a handle for the toolbar,
 and then doing


 {{{
 var filters = toolbar.get( 'filters' );

 if ( this.get( 'type' ) == 'image' ) {
         // update all
         filters.filters.all.text = acf.__( 'All images' );

         // remove some filters
         delete filters.filters.audio;
         delete filters.filters.video;
         delete filters.filters.image;
 }
 }}}

 etc.

 This is no longer working as of [61757] -- `filters.filters` is now
 `undefined`.

 The reason for this is that [61757] wrapped the media attachment filters
 `<select>` and its `<label>` in a container `<div>` for accessibility
 purposes. However, this changes the return value of
 `toolbar.get('filters')` from the `AttachmentFilters` view instance to the
 `wp.media.View` corresponding to the `<div>`, breaking plugins that rely
 on this to customize the media library filters.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/64948>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list