| 1136 | |
| 1137 | /** |
| 1138 | * @ticket 35045 |
| 1139 | * @ticket 33641 |
| 1140 | */ |
| 1141 | function test_wp_make_content_images_responsive_schemes() { |
| 1142 | $image_meta = wp_get_attachment_metadata( self::$large_id ); |
| 1143 | $size_array = $this->_get_image_size_array_from_name( 'medium' ); |
| 1144 | |
| 1145 | $srcset = sprintf( 'srcset="%s"', wp_get_attachment_image_srcset( self::$large_id, $size_array, $image_meta ) ); |
| 1146 | $sizes = sprintf( 'sizes="%s"', wp_get_attachment_image_sizes( self::$large_id, $size_array, $image_meta ) ); |
| 1147 | |
| 1148 | // Build HTML for the editor. |
| 1149 | $img = get_image_tag( self::$large_id, '', '', '', 'medium' ); |
| 1150 | $img_https = str_replace( 'http://', 'https://', $img ); |
| 1151 | $img_relative = str_replace( 'http://', '//', $img ); |
| 1152 | |
| 1153 | // Manually add srcset and sizes to the markup from get_image_tag(); |
| 1154 | $respimg = preg_replace( '|<img ([^>]+) />|', '<img $1 ' . $srcset . ' ' . $sizes . ' />', $img ); |
| 1155 | $respimg_https = preg_replace( '|<img ([^>]+) />|', '<img $1 ' . $srcset . ' ' . $sizes . ' />', $img_https ); |
| 1156 | $respimg_relative = preg_replace( '|<img ([^>]+) />|', '<img $1 ' . $srcset . ' ' . $sizes . ' />', $img_relative ); |
| 1157 | |
| 1158 | $content = ' |
| 1159 | <p>Image, http: protocol. Should have srcset and sizes.</p> |
| 1160 | %1$s |
| 1161 | |
| 1162 | <p>Image, http: protocol. Should have srcset and sizes.</p> |
| 1163 | %2$s |
| 1164 | |
| 1165 | <p>Image, protocol-relative. Should have srcset and sizes.</p> |
| 1166 | %3$s'; |
| 1167 | |
| 1168 | $unfiltered = sprintf( $content, $img, $img_https, $img_relative ); |
| 1169 | $expected = sprintf( $content, $respimg, $respimg_https, $respimg_relative ); |
| 1170 | $actual = wp_make_content_images_responsive( $unfiltered ); |
| 1171 | |
| 1172 | $this->assertSame( $expected, $actual ); |
| 1173 | } |