Make WordPress Core

Changeset 35595


Ignore:
Timestamp:
11/10/2015 01:58:38 AM (11 years ago)
Author:
azaozz
Message:

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

See #21389.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/theme.php

    r35594 r35595  
    995995
    996996/**
    997  * Create image markup for a custom header image.
     997 * Create image tag markup for a custom header image.
    998998 *
    999999 * @since 4.4.0
    10001000 *
    1001  * @param array $attr Optional. Attributes for the image markup. Default empty.
    1002  * @return string HTML element or empty string on failure.
     1001 * @param array $attr Optional. Additional attributes for the image tag. Can be used
     1002 *                              to override the default attributes. Default empty.
     1003 * @return string HTML image element markup or empty string on failure.
    10031004 */
    10041005function get_header_image_tag( $attr = array() ) {
     
    10281029
    10291030                if ( is_array( $image_meta ) ) {
    1030                         $srcset = wp_calculate_image_srcset( $header->url, $size_array, $image_meta, $header->attachment_id );
    1031                         $sizes = wp_get_attachment_image_sizes( $size_array, $image_meta, $header->attachment_id, $header->url );
    1032 
    1033                         if ( $srcset && ( $sizes || ! empty( $attr['sizes'] ) ) ) {
     1031                        $srcset = wp_calculate_image_srcset( $size_array, $header->url, $image_meta, $header->attachment_id );
     1032                        $sizes = ! empty( $attr['sizes'] ) ? $attr['sizes'] : wp_calculate_image_sizes( $size_array, $header->url, $image_meta, $header->attachment_id );
     1033
     1034                        if ( $srcset && $sizes ) {
    10341035                                $attr['srcset'] = $srcset;
    1035 
    1036                                 if ( empty( $attr['sizes'] ) ) {
    1037                                         $attr['sizes'] = $sizes;
    1038                                 }
     1036                                $attr['sizes'] = $sizes;
    10391037                        }
    10401038                }
     
    10551053         * @since 4.4.0
    10561054         *
    1057          * @param string $html   The HTML markup being filtered.
    1058          * @param object $header The custom header object returned by 'get_custom_header()'
    1059          * @param array  $attr   An array of attributes for the image markup.
     1055         * @param string $html   The HTML image tag markup being filtered.
     1056         * @param object $header The custom header object returned by 'get_custom_header()'.
     1057         * @param array  $attr   Array of the attributes for the image tag.
    10601058         */
    10611059        return apply_filters( 'get_header_image_tag', $html, $header, $attr );
Note: See TracChangeset for help on using the changeset viewer.