Make WordPress Core

Ticket #32363: 32363.4.patch

File 32363.4.patch, 2.0 KB (added by eclev91, 11 years ago)

Added docblock, changed name of filter

  • src/wp-includes/media.php

     
    688688 * @return bool|array Returns an array (url, width, height), or false, if no image is available.
    689689 */
    690690function wp_get_attachment_image_src( $attachment_id, $size = 'thumbnail', $icon = false ) {
    691 
     691        $image = false;
    692692        // get a thumbnail or intermediate image if there is one
    693         if ( $image = image_downsize($attachment_id, $size) )
    694                 return $image;
     693        $image = image_downsize($attachment_id, $size);
     694        if(!$image) {
     695                $src = false;
    695696
    696         $src = false;
     697                if ( $icon && $src = wp_mime_type_icon($attachment_id) ) {
     698                        /** This filter is documented in wp-includes/post.php */
     699                        $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/media' );
    697700
    698         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' );
    701 
    702                 $src_file = $icon_dir . '/' . wp_basename($src);
    703                 @list($width, $height) = getimagesize($src_file);
     701                        $src_file = $icon_dir . '/' . wp_basename($src);
     702                        @list($width, $height) = getimagesize($src_file);
     703                }
     704                if ( $src && $width && $height )
     705                        $image = array( $src, $width, $height );
    704706        }
    705         if ( $src && $width && $height )
    706                 return array( $src, $width, $height );
    707         return false;
     707        /**
     708         * Filter the image src result
     709         *
     710         * @since 4.3.0
     711         *
     712         * @param mixed                 $image                  either array with src, width & height, icon src, or false.
     713         * @param int                   $attachment_id  Image attachment ID.
     714         * @param string|array  $size           Optional. Registered image size to retrieve the source for or a flat
     715         *                                      array of height and width dimensions. Default 'thumbnail'.
     716         * @param bool                  $icon Optional. Whether the image should be treated as an icon. Default false.
     717         */
     718        return apply_filters('attachment_image_src', $image, $attachment_id, $size, $icon);
    708719}
    709720
    710721/**