Ticket #35030: 35030.2.patch
File 35030.2.patch, 2.0 KB (added by , 9 years ago) |
---|
-
src/wp-includes/media.php
1062 1062 */ 1063 1063 $src_matched = false; 1064 1064 1065 $is_iOS = ( wp_is_mobile() && strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false ); 1066 1065 1067 /* 1066 1068 * Loop through available images. Only use images that are resized 1067 1069 * versions of the same edit. 1068 1070 */ 1069 1071 foreach ( $image_sizes as $image ) { 1072 $is_src = false; 1070 1073 1071 1074 // Check if image meta isn't corrupted. 1072 1075 if ( ! is_array( $image ) ) { … … 1075 1078 1076 1079 // If the file name is part of the `src`, we've confirmed a match. 1077 1080 if ( ! $src_matched && false !== strpos( $image_src, $dirname . $image['file'] ) ) { 1078 $src_matched = true;1081 $src_matched = $is_src = true; 1079 1082 } 1080 1083 1081 1084 // Filter out images that are from previous edits. … … 1087 1090 * Filter out images that are wider than '$max_srcset_image_width' unless 1088 1091 * that file is in the 'src' attribute. 1089 1092 */ 1090 if ( $max_srcset_image_width && $image['width'] > $max_srcset_image_width && 1091 false === strpos( $image_src, $image['file'] ) ) { 1092 1093 if ( $max_srcset_image_width && $image['width'] > $max_srcset_image_width && ! $is_src ) { 1093 1094 continue; 1094 1095 } 1095 1096 … … 1109 1110 // If the image dimensions are within 1px of the expected size, use it. 1110 1111 if ( abs( $constrained_size[0] - $expected_size[0] ) <= 1 && abs( $constrained_size[1] - $expected_size[1] ) <= 1 ) { 1111 1112 // Add the URL, descriptor, and value to the sources array to be returned. 1112 $source s[ $image['width'] ]= array(1113 $source = array( 1113 1114 'url' => $image_baseurl . $image['file'], 1114 1115 'descriptor' => 'w', 1115 1116 'value' => $image['width'], 1116 1117 ); 1118 1119 // iOS 8 is buggy. Make sure the src URL is first in the srcset. 1120 if ( $is_iOS && $is_src ) { 1121 $sources = array_merge( array( $image['width'] => $source ), $sources ); 1122 } else { 1123 $sources[ $image['width'] ] = $source; 1124 } 1117 1125 } 1118 1126 } 1119 1127