diff --git src/wp-includes/media.php src/wp-includes/media.php
index 6b0187a..7820526 100644
|
|
function wp_calculate_image_srcset( $size_array, $image_src, $image_meta, $attac |
1028 | 1028 | $image_baseurl = trailingslashit( $upload_dir['baseurl'] ) . $dirname; |
1029 | 1029 | |
1030 | 1030 | /* |
| 1031 | * If currently on SSL, prefer HTTPS URLs when we know they're supported by the domain |
| 1032 | * (which is to say, when they share the domain name of the current SSL page). |
| 1033 | */ |
| 1034 | if ( is_ssl() && 'https' !== substr( $image_baseurl, 0, 5 ) && parse_url( $image_baseurl, PHP_URL_HOST ) === $_SERVER['HTTP_HOST'] ) { |
| 1035 | $image_baseurl = set_url_scheme( $image_baseurl, 'https' ); |
| 1036 | } |
| 1037 | |
| 1038 | /* |
1031 | 1039 | * Images that have been edited in WordPress after being uploaded will |
1032 | 1040 | * contain a unique hash. Look for that hash and use it later to filter |
1033 | 1041 | * out images that are leftovers from previous versions. |
diff --git tests/phpunit/tests/media.php tests/phpunit/tests/media.php
index d5ae231..bdf3e2c 100644
|
|
EOF; |
1407 | 1407 | $actual = wp_make_content_images_responsive( $unfiltered ); |
1408 | 1408 | |
1409 | 1409 | $this->assertSame( $expected, $actual ); |
| 1410 | } |
| 1411 | |
| 1412 | /** |
| 1413 | * @ticket 34945 |
| 1414 | * @ticket 33641 |
| 1415 | */ |
| 1416 | function test_wp_get_attachment_image_with_https_on() { |
| 1417 | // Save server data for cleanup |
| 1418 | $is_ssl = is_ssl(); |
| 1419 | |
| 1420 | // Mock meta for the image. |
| 1421 | $image_meta = array( |
| 1422 | 'width' => 1200, |
| 1423 | 'height' => 600, |
| 1424 | 'file' => 'test.jpg', |
| 1425 | 'sizes' => array( |
| 1426 | 'thumbnail' => array( |
| 1427 | 'file' => 'test-150x150.jpg', |
| 1428 | 'width' => 150, |
| 1429 | 'height' => 150, |
| 1430 | ), |
| 1431 | 'medium' => array( |
| 1432 | 'file' => 'test-300x150.jpg', |
| 1433 | 'width' => 300, |
| 1434 | 'height' => 150, |
| 1435 | ), |
| 1436 | 'large' => array( |
| 1437 | 'file' => 'test-1024x512.jpg', |
| 1438 | 'width' => 1024, |
| 1439 | 'height' => 512, |
| 1440 | ), |
| 1441 | ) |
| 1442 | ); |
| 1443 | |
| 1444 | // Test using the large file size. |
| 1445 | $size_array = array(1024, 512); |
| 1446 | $image_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_meta['sizes']['large']['file']; |
| 1447 | |
| 1448 | $_SERVER['HTTPS'] = 'on'; |
| 1449 | |
| 1450 | $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'; |
| 1451 | |
| 1452 | $this->assertSame( $expected, wp_calculate_image_srcset( $size_array, $image_url, $image_meta ) ); |
| 1453 | |
| 1454 | // Cleanup |
| 1455 | $_SERVER['HTTPS'] = $is_ssl; |
1410 | 1456 | } |
1411 | 1457 | } |