diff --git a/wp-includes/media.php b/wp-includes/media.php index 57037710b0..c232d8e6a3 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -693,23 +693,35 @@ function get_intermediate_image_sizes() { * @return false|array Returns an array (url, width, height), or false, if no image is available. */ function wp_get_attachment_image_src( $attachment_id, $size = 'thumbnail', $icon = false ) { - // get a thumbnail or intermediate image if there is one - if ( $image = image_downsize($attachment_id, $size) ) - return $image; + $image = image_downsize( $attachment_id, $size ); + if ( ! $image ) { + $src = false; - $src = false; + if ( $icon && $src = wp_mime_type_icon( $attachment_id ) ) { + /** This filter is documented in wp-includes/post.php */ + $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/media' ); - if ( $icon && $src = wp_mime_type_icon($attachment_id) ) { - /** This filter is documented in wp-includes/post.php */ - $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/media' ); + $src_file = $icon_dir . '/' . wp_basename( $src ); + @list( $width, $height ) = getimagesize( $src_file ); + } - $src_file = $icon_dir . '/' . wp_basename($src); - @list($width, $height) = getimagesize($src_file); + if ( $src && $width && $height ) { + $image = array( $src, $width, $height ); + } } - if ( $src && $width && $height ) - return array( $src, $width, $height ); - return false; + /** + * Filter the image src result + * + * @since 4.3.0 + * + * @param array|false $image Either array with src, width & height, icon src, or false. + * @param int $attachment_id Image attachment ID. + * @param string|array $size Optional. Registered image size to retrieve the source for or a flat + * array of height and width dimensions. Default 'thumbnail'. + * @param bool $icon Optional. Whether the image should be treated as an icon. Default false. + */ + return apply_filters( 'attachment_image_src', $image, $attachment_id, $size, $icon ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 7553c7da27..4d7da56819 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.3-alpha-32865'; +$wp_version = '4.3-alpha-32866'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.