Changeset 33705
- Timestamp:
- 08/22/2015 04:38:09 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r33643 r33705 3432 3432 $path = $url; 3433 3433 3434 $site_url = parse_url( $dir['url'] ); 3435 $image_path = parse_url( $path ); 3436 3437 //force the protocols to match if needed 3438 if ( isset( $image_path['scheme'] ) && ( $image_path['scheme'] !== $site_url['scheme'] ) ) { 3439 $path = str_replace( $image_path['scheme'], $site_url['scheme'], $path ); 3440 } 3441 3434 3442 if ( 0 === strpos( $path, $dir['baseurl'] . '/' ) ) { 3435 3443 $path = substr( $path, strlen( $dir['baseurl'] . '/' ) ); … … 3450 3458 * @param string $url The URL being looked up. 3451 3459 */ 3452 $post_id = apply_filters( 'attachment_url_to_postid', $post_id, $url ); 3453 3454 return (int) $post_id; 3460 return (int) apply_filters( 'attachment_url_to_postid', $post_id, $url ); 3455 3461 } 3456 3462 -
trunk/tests/phpunit/tests/media.php
r33506 r33705 534 534 $image_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_path; 535 535 $this->assertEquals( $attachment_id, attachment_url_to_postid( $image_url ) ); 536 } 537 538 function test_attachment_url_to_postid_schemes() { 539 $image_path = '2014/11/' . $this->img_name; 540 $attachment_id = $this->factory->attachment->create_object( $image_path, 0, array( 541 'post_mime_type' => 'image/jpeg', 542 'post_type' => 'attachment', 543 ) ); 544 545 /** 546 * @ticket 33109 Testing protocols not matching 547 */ 548 $image_url = 'https://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_path; 549 $this->assertEquals( $attachment_id, attachment_url_to_postid( $image_url ) ); 550 } 551 552 function test_attachment_url_to_postid_filtered() { 553 $image_path = '2014/11/' . $this->img_name; 554 $attachment_id = $this->factory->attachment->create_object( $image_path, 0, array( 555 'post_mime_type' => 'image/jpeg', 556 'post_type' => 'attachment', 557 ) ); 536 558 537 559 add_filter( 'upload_dir', array( $this, '_upload_dir' ) );
Note: See TracChangeset
for help on using the changeset viewer.