diff --git src/wp-includes/media.php src/wp-includes/media.php
index 7a41653..38dd268 100644
|
|
function _wp_upload_dir_baseurl() { |
917 | 917 | |
918 | 918 | if ( empty( $baseurl[$blog_id] ) ) { |
919 | 919 | $uploads_dir = wp_upload_dir(); |
920 | | $baseurl[$blog_id] = $uploads_dir['baseurl']; |
| 920 | /* |
| 921 | * If currently on SSL, prefer HTTPS URLs when we know they're supported by the domain |
| 922 | * (which is to say, when they share the domain name of the current SSL page). |
| 923 | */ |
| 924 | if ( is_ssl() && 'https' !== substr( $uploads_dir['baseurl'], 0, 5 ) && parse_url( $uploads_dir['baseurl'], PHP_URL_HOST ) === $_SERVER['HTTP_HOST'] ) { |
| 925 | $baseurl[$blog_id] = set_url_scheme( $uploads_dir['baseurl'] ); |
| 926 | } |
921 | 927 | } |
922 | 928 | |
923 | 929 | return $baseurl[$blog_id]; |
diff --git tests/phpunit/tests/media.php tests/phpunit/tests/media.php
index 5fa4fab..214c597 100644
|
|
EOF; |
1302 | 1302 | $actual = wp_make_content_images_responsive( $unfiltered ); |
1303 | 1303 | |
1304 | 1304 | $this->assertSame( $expected, $actual ); |
| 1305 | } |
| 1306 | |
| 1307 | /** |
| 1308 | * @ticket 34945 |
| 1309 | * @ticket 33641 |
| 1310 | */ |
| 1311 | function test_wp_get_attachment_image_with_https_on() { |
| 1312 | // Save server data for cleanup |
| 1313 | $is_ssl = is_ssl(); |
| 1314 | |
| 1315 | // Mock meta for the image. |
| 1316 | $image_meta = array( |
| 1317 | 'width' => 1200, |
| 1318 | 'height' => 600, |
| 1319 | 'file' => 'test.jpg', |
| 1320 | 'sizes' => array( |
| 1321 | 'thumbnail' => array( |
| 1322 | 'file' => 'test-150x150.jpg', |
| 1323 | 'width' => 150, |
| 1324 | 'height' => 150, |
| 1325 | ), |
| 1326 | 'medium' => array( |
| 1327 | 'file' => 'test-300x150.jpg', |
| 1328 | 'width' => 300, |
| 1329 | 'height' => 150, |
| 1330 | ), |
| 1331 | 'large' => array( |
| 1332 | 'file' => 'test-1024x512.jpg', |
| 1333 | 'width' => 1024, |
| 1334 | 'height' => 512, |
| 1335 | ), |
| 1336 | ) |
| 1337 | ); |
| 1338 | |
| 1339 | // Test using the large file size. |
| 1340 | $size_array = array(1024, 512); |
| 1341 | $image_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_meta['sizes']['large']['file']; |
| 1342 | |
| 1343 | $_SERVER['HTTPS'] = 'on'; |
| 1344 | |
| 1345 | $expected = 'https://example.org/wp-content/uploads/test-300x150.jpg 300w, https://example.org/wp-content/uploads/test-1024x512.jpg 1024w, https://example.org/wp-content/uploads/test.jpg 1200w'; |
| 1346 | |
| 1347 | $this->assertSame( $expected, wp_calculate_image_srcset( $size_array, $image_url, $image_meta ) ); |
| 1348 | |
| 1349 | // Cleanup |
| 1350 | $_SERVER['HTTPS'] = $is_ssl; |
1305 | 1351 | } |
1306 | 1352 | } |