Make WordPress Core

Opened 14 months ago

Last modified 14 months ago

#24430 new defect (bug)

inconsistent icon_dir/icon_dirs use in wp_mime_type_icon and wp_get_attachment_image_src

Reported by: dglingren Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 2.5
Component: Media Keywords:
Focuses: Cc:


/wp-includes/post.php function wp_mime_type_icon allows for multiple icon image directories by applying the "icon_dirs" filter:

if ( !is_array($icon_files) ) {
    $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/crystal' );
    $icon_dir_uri = apply_filters( 'icon_dir_uri', includes_url('images/crystal') );
    $dirs = apply_filters( 'icon_dirs', array($icon_dir => $icon_dir_uri) );
    $icon_files = array();
    while ( $dirs ) {

However, /wp-includes/media.php function wp_get_attachment_image_src does not apply the "icon_dirs" filter:

if ( $icon && $src = wp_mime_type_icon($attachment_id) ) {
    $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/crystal' );
    $src_file = $icon_dir . '/' . wp_basename($src);
    @list($width, $height) = getimagesize($src_file);

The base filename is always combined with the default Wordress directory path and passed to getimagesize. This means that any additional directories will never be passed to getimagesize(), and an incorrect size or no size at all will be used for any icon image files not sourced from the WordPress default directory.

Change History (1)

comment:1 SergeyBiryukov14 months ago

  • Component changed from Plugins to Media
  • Version changed from 3.5.1 to 2.5

Related: #20205

Note: See TracTickets for help on using tickets.