[wp-trac] [WordPress Trac] #60740: wp_mime_type_icon function fails to return non-SVG icons

WordPress Trac noreply at wordpress.org
Sun Mar 10 22:57:51 UTC 2024


#60740: wp_mime_type_icon function fails to return non-SVG icons
--------------------------+-----------------------------
 Reporter:  dglingren     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 WordPress 6.5 added a new parameter, $preferred_ext, to the
 wp_mime_type_icon function in the /wp-includes/post.php file. It is
 described as "File format to prefer in return." In fact, it is the
 REQUIRED extension, not the preferred extension, and no other file
 extension is allowed. WordPress passes ".svg" in the argument and that
 prevents any other file type, e.g., a ".png" icon, from being returned.

 You can reproduce the problem by activating a plugin that supplies a
 custom icon directory with non-SVG icon files, such as my own Media
 Library Assistant. Simply install and activate the plugin, then go to the
 Settings/Media Library Assistant Uploads tab. Check the "Enable MLA File
 Type Icons Support" box and click Save Changes. The go to the
 Media/Library or Media/Assistant admin screen and display a non-image item
 such as an audio or video item.

 When this bug occurs the wp_mime_type_icon function causes a PHP Warning
 message. "Undefined variable $icon in ...\wp-includes\post.php on line
 6940", and the function returns a NULL value. The function also caches an
 empty array for the $icon_files variable so subsequent function calls
 return a false value.

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


More information about the wp-trac mailing list