Changeset 30501
- Timestamp:
- 11/21/2014 06:34:23 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r30422 r30501 3270 3270 3271 3271 $dir = wp_upload_dir(); 3272 $path = ltrim( $url, $dir['baseurl'] . '/' ); 3272 $path = $url; 3273 3274 if ( 0 === strpos( $path, $dir['baseurl'] . '/' ) ) { 3275 $path = substr( $path, strlen( $dir['baseurl'] . '/' ) ); 3276 } 3273 3277 3274 3278 $sql = $wpdb->prepare( -
trunk/tests/phpunit/tests/media.php
r30132 r30501 444 444 } 445 445 446 /** 447 * @ticket 30346 448 */ 449 function test_attachment_url_to_postid() { 450 $image_path = '2014/11/' . $this->img_name; 451 $attachment_id = $this->factory->attachment->create_object( $image_path, 0, array( 452 'post_mime_type' => 'image/jpeg', 453 'post_type' => 'attachment', 454 ) ); 455 456 $image_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_path; 457 $this->assertEquals( $attachment_id, attachment_url_to_postid( $image_url ) ); 458 459 add_filter( 'upload_dir', array( $this, '_upload_dir' ) ); 460 $image_url = 'http://192.168.1.20.com/wp-content/uploads/' . $image_path; 461 $this->assertEquals( $attachment_id, attachment_url_to_postid( $image_url ) ); 462 remove_filter( 'upload_dir', array( $this, '_upload_dir' ) ); 463 } 464 465 function _upload_dir( $dir ) { 466 $dir['baseurl'] = 'http://192.168.1.20.com/wp-content/uploads'; 467 return $dir; 468 } 469 446 470 }
Note: See TracChangeset
for help on using the changeset viewer.