[wp-trac] [WordPress Trac] #32544: No function exposes all supported MIME types

WordPress Trac noreply at wordpress.org
Wed Jun 1 22:44:18 UTC 2016


#32544: No function exposes all supported MIME types
-------------------------------------------------+-------------------------
 Reporter:  dan.rossiter                         |       Owner:
     Type:  enhancement                          |      Status:  new
 Priority:  low                                  |   Milestone:  Awaiting
Component:  Media                                |  Review
 Severity:  normal                               |     Version:  4.2.2
 Keywords:  good-first-bug has-patch has-unit-   |  Resolution:
  tests                                          |     Focuses:
-------------------------------------------------+-------------------------
Changes (by octalmage):

 * keywords:  needs-patch good-first-bug => good-first-bug has-patch has-
     unit-tests


Comment:

 The patch I attached contains a solution. Like @dan.rossiter said, it's
 the best solution that doesn't involve refactoring how mime types are
 handled. This won't change anything unless plugin/theme developers obey
 the new $ignore_user flag. It works like this:

 {{{#!php
 add_filter( 'upload_mimes', 'user_mimes', 10, 2 );

 function user_mimes( $mimes, $user_id, $ignore_user ) {
         $mime_types = array( 'test' => 'text/test' );

         $user = get_userdata( $user_id );
         if ( $ignore_user ) {
                 $mimes = array_merge( $mimes, $mime_types );
         }
         else if ( $user && $user->user_firstname === 'Abe' ) {
                 $mimes = array_merge( $mimes, $mime_types );
         }

         return $mimes;
 }
 }}}

 Basically developers would need to return all of the mime types their code
 adds if the $ignore_user flag is true.

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


More information about the wp-trac mailing list