WordPress.org

Make WordPress Core

Ticket #20205: 20205.3.patch

File 20205.3.patch, 1.3 KB (added by jfarthing84, 5 years ago)

Filter wp_attachment_image_src instead.

  • wp-includes/media.php

     
    508508function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = false) {
    509509
    510510        // get a thumbnail or intermediate image if there is one
    511         if ( $image = image_downsize($attachment_id, $size) )
    512                 return $image;
     511        if ( ! $image = image_downsize( $attachment_id, $size ) ) {
    513512
    514         $src = false;
     513                $src = false;
    515514
    516         if ( $icon && $src = wp_mime_type_icon($attachment_id) ) {
    517                 $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/crystal' );
    518                 $src_file = $icon_dir . '/' . wp_basename($src);
    519                 @list($width, $height) = getimagesize($src_file);
     515                if ( $icon && $src = wp_mime_type_icon( $attachment_id ) ) {
     516                        $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/crystal' );
     517                        $src_file = $icon_dir . '/' . wp_basename( $src );
     518                        @list( $width, $height ) = getimagesize( $src_file );
     519
     520                        if ( $src && $width && $height )
     521                                $image = array( $src, $width, $height );
     522                }
    520523        }
    521         if ( $src && $width && $height )
    522                 return array( $src, $width, $height );
    523         return false;
     524        return apply_filters( 'wp_attachment_image_src', $image, $attachment_id, $size, $icon );
    524525}
    525526
    526527/**