After [35402], don't unnecessary run `wp_get_attachment_image_srcset()` and `wp_get_attachment_image_sizes()` in `wp_get_attachment_image()` if `srcset` is passed as an argument.

See #34379.
Built from https://develop.svn.wordpress.org/trunk@35404


git-svn-id: http://core.svn.wordpress.org/trunk@35368 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2015-10-26 18:40:24 +00:00
parent e3989c6194
commit 1e59e53dd2
2 changed files with 11 additions and 8 deletions

View File

@ -810,17 +810,20 @@ function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = fa
$default_attr['alt'] = trim(strip_tags( $attachment->post_title )); // Finally, use the title $default_attr['alt'] = trim(strip_tags( $attachment->post_title )); // Finally, use the title
$attr = wp_parse_args( $attr, $default_attr ); $attr = wp_parse_args( $attr, $default_attr );
// Generate srcset and sizes if not already present.
if ( empty( $attr['srcset'] ) ) {
$srcset = wp_get_attachment_image_srcset( $attachment_id, $size ); $srcset = wp_get_attachment_image_srcset( $attachment_id, $size );
$sizes = wp_get_attachment_image_sizes( $attachment_id, $size, $width ); $sizes = wp_get_attachment_image_sizes( $attachment_id, $size, $width );
// Generate srcset and sizes if not already present. if ( $srcset && $sizes ) {
if ( empty( $attr['srcset'] ) && $srcset && $sizes ) {
$attr['srcset'] = $srcset; $attr['srcset'] = $srcset;
if ( empty( $attr['sizes'] ) ) { if ( empty( $attr['sizes'] ) ) {
$attr['sizes'] = $sizes; $attr['sizes'] = $sizes;
} }
} }
}
/** /**
* Filter the list of attachment image attributes. * Filter the list of attachment image attributes.

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.4-beta1-35403'; $wp_version = '4.4-beta1-35404';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.