Make WordPress Core

Ticket #24430: 24430.diff

File 24430.diff, 1.1 KB (added by joostdekeijzer, 9 years ago)

method now uses 'icon_files' cache created by wp_mime_type_icon

  • media.php

     
    690690function wp_get_attachment_image_src( $attachment_id, $size = 'thumbnail', $icon = false ) {
    691691
    692692        // get a thumbnail or intermediate image if there is one
    693         if ( $image = image_downsize($attachment_id, $size) )
     693        if ( $image = image_downsize($attachment_id, $size) ) {
    694694                return $image;
     695        }
    695696
    696697        $src = false;
    697698
    698699        if ( $icon && $src = wp_mime_type_icon($attachment_id) ) {
    699                 /** This filter is documented in wp-includes/post.php */
    700                 $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/media' );
     700                // wp_mime_type_icon sets 'icon_files' cache
     701                @list($width, $height) = getimagesize(array_search($src, wp_cache_get('icon_files')));
     702        }
    701703
    702                 $src_file = $icon_dir . '/' . wp_basename($src);
    703                 @list($width, $height) = getimagesize($src_file);
     704        if ( $src && $width && $height ) {
     705                return array( $src, $width, $height );
    704706        }
    705         if ( $src && $width && $height )
    706                 return array( $src, $width, $height );
     707
    707708        return false;
    708709}
    709710