Responsive images: fix args order and streamline the srcset and sizes generation and better inline docs in `get_header_image_tag()`.

See #21389.
Built from https://develop.svn.wordpress.org/trunk@35595


git-svn-id: http://core.svn.wordpress.org/trunk@35559 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2015-11-10 01:59:25 +00:00
parent a86cac1676
commit f34c16674a
2 changed files with 12 additions and 14 deletions

View File

@ -994,12 +994,13 @@ function get_header_image() {
}
/**
* Create image markup for a custom header image.
* Create image tag markup for a custom header image.
*
* @since 4.4.0
*
* @param array $attr Optional. Attributes for the image markup. Default empty.
* @return string HTML element or empty string on failure.
* @param array $attr Optional. Additional attributes for the image tag. Can be used
* to override the default attributes. Default empty.
* @return string HTML image element markup or empty string on failure.
*/
function get_header_image_tag( $attr = array() ) {
$header = get_custom_header();
@ -1027,15 +1028,12 @@ function get_header_image_tag( $attr = array() ) {
$size_array = array( $width, $height );
if ( is_array( $image_meta ) ) {
$srcset = wp_calculate_image_srcset( $header->url, $size_array, $image_meta, $header->attachment_id );
$sizes = wp_get_attachment_image_sizes( $size_array, $image_meta, $header->attachment_id, $header->url );
$srcset = wp_calculate_image_srcset( $size_array, $header->url, $image_meta, $header->attachment_id );
$sizes = ! empty( $attr['sizes'] ) ? $attr['sizes'] : wp_calculate_image_sizes( $size_array, $header->url, $image_meta, $header->attachment_id );
if ( $srcset && ( $sizes || ! empty( $attr['sizes'] ) ) ) {
if ( $srcset && $sizes ) {
$attr['srcset'] = $srcset;
if ( empty( $attr['sizes'] ) ) {
$attr['sizes'] = $sizes;
}
$attr['sizes'] = $sizes;
}
}
}
@ -1054,9 +1052,9 @@ function get_header_image_tag( $attr = array() ) {
*
* @since 4.4.0
*
* @param string $html The HTML markup being filtered.
* @param object $header The custom header object returned by 'get_custom_header()'
* @param array $attr An array of attributes for the image markup.
* @param string $html The HTML image tag markup being filtered.
* @param object $header The custom header object returned by 'get_custom_header()'.
* @param array $attr Array of the attributes for the image tag.
*/
return apply_filters( 'get_header_image_tag', $html, $header, $attr );
}

View File

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