| | 437 | * Crop setting for PDF. |
| | 438 | * |
| | 439 | * @ticket 43226 |
| | 440 | */ |
| | 441 | public function test_crop_setting_for_pdf() { |
| | 442 | |
| | 443 | if ( ! wp_image_editor_supports( array( 'mime_type' => 'application/pdf' ) ) ) { |
| | 444 | $this->markTestSkipped( 'Rendering PDFs is not supported on this system.' ); |
| | 445 | } |
| | 446 | |
| | 447 | update_option( 'medium_crop', 1 ); |
| | 448 | |
| | 449 | $orig_file = DIR_TESTDATA . '/images/wordpress-gsoc-flyer.pdf'; |
| | 450 | $test_file = '/tmp/wordpress-gsoc-flyer.pdf'; |
| | 451 | copy( $orig_file, $test_file ); |
| | 452 | |
| | 453 | $attachment_id = $this->factory->attachment->create_object( |
| | 454 | $test_file, 0, array( |
| | 455 | 'post_mime_type' => 'application/pdf', |
| | 456 | ) |
| | 457 | ); |
| | 458 | |
| | 459 | $this->assertNotEmpty( $attachment_id ); |
| | 460 | |
| | 461 | $expected = array( |
| | 462 | 'sizes' => array( |
| | 463 | 'thumbnail' => array( |
| | 464 | 'file' => 'wordpress-gsoc-flyer-pdf-116x150.jpg', |
| | 465 | 'width' => 116, |
| | 466 | 'height' => 150, |
| | 467 | 'mime-type' => 'image/jpeg', |
| | 468 | ), |
| | 469 | 'medium' => array( |
| | 470 | 'file' => 'wordpress-gsoc-flyer-pdf-232x300.jpg', |
| | 471 | 'width' => 300, |
| | 472 | 'height' => 300, |
| | 473 | 'mime-type' => 'image/jpeg', |
| | 474 | ), |
| | 475 | 'large' => array( |
| | 476 | 'file' => 'wordpress-gsoc-flyer-pdf-791x1024.jpg', |
| | 477 | 'width' => 791, |
| | 478 | 'height' => 1024, |
| | 479 | 'mime-type' => 'image/jpeg', |
| | 480 | ), |
| | 481 | 'full' => array( |
| | 482 | 'file' => 'wordpress-gsoc-flyer-pdf.jpg', |
| | 483 | 'width' => 1088, |
| | 484 | 'height' => 1408, |
| | 485 | 'mime-type' => 'image/jpeg', |
| | 486 | ), |
| | 487 | ), |
| | 488 | ); |
| | 489 | |
| | 490 | $metadata = wp_generate_attachment_metadata( $attachment_id, $test_file ); |
| | 491 | $this->assertSame( $expected, $metadata ); |
| | 492 | |
| | 493 | unlink( $test_file ); |
| | 494 | foreach ( $metadata['sizes'] as $size ) { |
| | 495 | unlink( '/tmp/' . $size['file'] ); |
| | 496 | } |
| | 497 | } |
| | 498 | |
| | 499 | /** |