[wp-trac] [WordPress Trac] #22744: Media search doesn't include file name

WordPress Trac noreply at wordpress.org
Sun Sep 25 19:47:38 UTC 2016


#22744: Media search doesn't include file name
--------------------------------------+-----------------------------
 Reporter:  johnbillion               |       Owner:  joemcgill
     Type:  enhancement               |      Status:  reopened
 Priority:  normal                    |   Milestone:  4.7
Component:  Media                     |     Version:  3.0
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:  administration
--------------------------------------+-----------------------------

Comment (by kylegilman):

 I have a plugin that generates a number of attachments that usually don't
 need to show up in the Media Library list. I filter the Media Library
 query by only displaying items that don't have a particular custom meta
 key. It works in 4.6 and in 4.7 as long as
 `_filter_query_attachment_filenames()` is disabled.

 This is a more general action than I use, but simplified to reproduce the
 issue:

 {{{#!php
 add_action('pre_get_posts', 'kg_hide_based_on_meta_key');

 function kg_hide_based_on_meta_key( $query ) {

         $query->set(
                 'meta_query',
                 array(
                         array(
                                 'key' => '_anymetakey',
                                 'compare' => 'NOT EXISTS'
                         )
                 )
         );

 }
 }}}

 shouldn't change the results at all assuming `_anymetakey` is not in use,
 but it will result in an empty list in the Media Library. The list of
 Posts or any other query work fine as far as I can tell. If you change the
 key to a value we know an attachment will have and remove `compare` then
 the full list is shown.

 {{{#!php
 add_action('pre_get_posts', 'kg_hide_based_on_meta_key');

 function kg_hide_based_on_meta_key( $query ) {

         $query->set(
                 'meta_query',
                 array(
                         array(
                                 'key' => '_wp_attachment_metadata'
                         )
                 )
         );

 }
 }}}

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


More information about the wp-trac mailing list