Make WordPress Core


Ignore:
Timestamp:
03/18/2016 07:44:50 PM (9 years ago)
Author:
azaozz
Message:

Responsive Images: the src of the image has to be first in the srcset, because of a bug in iOS8. Update the unit tests to reflect the changes.

Props jaspermdegroot, joemcgill, azaozz.
Fixes #35030.

File:
1 edited

Legend:

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

    r37022 r37034  
    10681068     */
    10691069    foreach ( $image_sizes as $image ) {
     1070        $is_src = false;
    10701071
    10711072        // Check if image meta isn't corrupted.
     
    10761077        // If the file name is part of the `src`, we've confirmed a match.
    10771078        if ( ! $src_matched && false !== strpos( $image_src, $dirname . $image['file'] ) ) {
    1078             $src_matched = true;
     1079            $src_matched = $is_src = true;
    10791080        }
    10801081
     
    10881089         * that file is in the 'src' attribute.
    10891090         */
    1090         if ( $max_srcset_image_width && $image['width'] > $max_srcset_image_width &&
    1091             false === strpos( $image_src, $image['file'] ) ) {
    1092 
     1091        if ( $max_srcset_image_width && $image['width'] > $max_srcset_image_width && ! $is_src ) {
    10931092            continue;
    10941093        }
     
    11101109        if ( abs( $constrained_size[0] - $expected_size[0] ) <= 1 && abs( $constrained_size[1] - $expected_size[1] ) <= 1 ) {
    11111110            // Add the URL, descriptor, and value to the sources array to be returned.
    1112             $sources[ $image['width'] ] = array(
     1111            $source = array(
    11131112                'url'        => $image_baseurl . $image['file'],
    11141113                'descriptor' => 'w',
    11151114                'value'      => $image['width'],
    11161115            );
     1116
     1117            // The 'src' image has to be the first in the 'srcset', because of a bug in iOS8. See #35030.
     1118            if ( $is_src ) {
     1119                $sources = array( $image['width'] => $source ) + $sources;
     1120            } else {
     1121                $sources[ $image['width'] ] = $source;
     1122            }
    11171123        }
    11181124    }
Note: See TracChangeset for help on using the changeset viewer.