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.
Built from https://develop.svn.wordpress.org/trunk@37034


git-svn-id: http://core.svn.wordpress.org/trunk@37001 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2016-03-18 19:45:26 +00:00
parent 3be543d7af
commit d508fcdb51
2 changed files with 12 additions and 6 deletions

View File

@ -1067,6 +1067,7 @@ function wp_calculate_image_srcset( $size_array, $image_src, $image_meta, $attac
* versions of the same edit.
*/
foreach ( $image_sizes as $image ) {
$is_src = false;
// Check if image meta isn't corrupted.
if ( ! is_array( $image ) ) {
@ -1075,7 +1076,7 @@ function wp_calculate_image_srcset( $size_array, $image_src, $image_meta, $attac
// If the file name is part of the `src`, we've confirmed a match.
if ( ! $src_matched && false !== strpos( $image_src, $dirname . $image['file'] ) ) {
$src_matched = true;
$src_matched = $is_src = true;
}
// Filter out images that are from previous edits.
@ -1087,9 +1088,7 @@ function wp_calculate_image_srcset( $size_array, $image_src, $image_meta, $attac
* Filter out images that are wider than '$max_srcset_image_width' unless
* that file is in the 'src' attribute.
*/
if ( $max_srcset_image_width && $image['width'] > $max_srcset_image_width &&
false === strpos( $image_src, $image['file'] ) ) {
if ( $max_srcset_image_width && $image['width'] > $max_srcset_image_width && ! $is_src ) {
continue;
}
@ -1109,11 +1108,18 @@ function wp_calculate_image_srcset( $size_array, $image_src, $image_meta, $attac
// If the image dimensions are within 1px of the expected size, use it.
if ( abs( $constrained_size[0] - $expected_size[0] ) <= 1 && abs( $constrained_size[1] - $expected_size[1] ) <= 1 ) {
// Add the URL, descriptor, and value to the sources array to be returned.
$sources[ $image['width'] ] = array(
$source = array(
'url' => $image_baseurl . $image['file'],
'descriptor' => 'w',
'value' => $image['width'],
);
// The 'src' image has to be the first in the 'srcset', because of a bug in iOS8. See #35030.
if ( $is_src ) {
$sources = array( $image['width'] => $source ) + $sources;
} else {
$sources[ $image['width'] ] = $source;
}
}
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-beta4-37033';
$wp_version = '4.5-beta4-37034';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.