[wp-trac] [WordPress Trac] #36418: Custom MIME type icons lost in WP Media List view

WordPress Trac noreply at wordpress.org
Sat Oct 23 13:22:49 UTC 2021


#36418: Custom MIME type icons lost in WP Media List view
--------------------------+------------------------------
 Reporter:  jhorowitz     |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Media         |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  dev-feedback  |     Focuses:  administration
--------------------------+------------------------------

Comment (by liquidRock):

 This bug still exists if you try to load custom icon images by filtering
 `wp_mime_type_icon`. They work fine in Grid view of the Media Library, but
 if you view as List, it ignores the custom path and tries to find them in
 the core media directory, throws PHP errors, and no image is loaded at
 all.

 Here's an example I tried in functions.php of a custom theme. Works in
 Grid view, fails in List view.

 {{{#!php
 <?php
 add_filter( 'wp_mime_type_icon', function( $icon, $mime, $post_id )
 {
     if( 'text/plain' === $mime && $post_id > 0 )
         $icon = get_template_directory_uri() .
 '/library/images/icons/txt.png';

     if( 'application/pdf' === $mime && $post_id > 0 )
         $icon = get_template_directory_uri() .
 '/library/images/icons/pdf.png';

     return $icon;
 }, 10, 3 );
 }}}

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


More information about the wp-trac mailing list