| 446 | /** |
| 447 | * @ticket 30320 |
| 448 | */ |
| 449 | function test_attachment_is_image() { |
| 450 | $filename = 'CapitalExt.JPG'; |
| 451 | $filetype = wp_check_filetype( basename( $filename ), null ); |
| 452 | $wp_upload_dir = wp_upload_dir(); |
| 453 | |
| 454 | //Add an attachment with the post_mime_type. |
| 455 | $attachment = array( |
| 456 | 'guid' => $wp_upload_dir[ 'url' ] . '/' . basename( $filename ), |
| 457 | 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ), |
| 458 | 'post_content' => '', |
| 459 | 'post_status' => 'inherit', |
| 460 | 'post_mime_type' => $filetype[ 'type' ], |
| 461 | ); |
| 462 | // Insert the attachment. |
| 463 | $attach_id = wp_insert_attachment( $attachment, $filename ); |
| 464 | $this->assertTrue( wp_attachment_is_image( $attach_id ) ); |
| 465 | |
| 466 | //Add an attachment without the post_mime_type. |
| 467 | $attachment = array( |
| 468 | 'guid' => $wp_upload_dir[ 'url' ] . '/' . basename( $filename ), |
| 469 | 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ), |
| 470 | 'post_content' => '', |
| 471 | 'post_status' => 'inherit' |
| 472 | ); |
| 473 | // Insert the attachment. |
| 474 | $attach_id = wp_insert_attachment( $attachment, $filename ); |
| 475 | $this->assertFalse( wp_attachment_is_image( $attach_id ) ); |