Changeset 42792
- Timestamp:
- 03/07/2018 01:18:08 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/image.php
r42780 r42792 254 254 } else { 255 255 // Force thumbnails to be soft crops. 256 if ( ! 'thumbnail' === $s ) {256 if ( 'thumbnail' !== $s ) { 257 257 $sizes[ $s ]['crop'] = get_option( "{$s}_crop" ); 258 258 } -
trunk/tests/phpunit/tests/image/functions.php
r42780 r42792 445 445 446 446 /** 447 * Crop setting for PDF. 448 * 449 * @ticket 43226 450 */ 451 public function test_crop_setting_for_pdf() { 452 453 if ( ! wp_image_editor_supports( array( 'mime_type' => 'application/pdf' ) ) ) { 454 $this->markTestSkipped( 'Rendering PDFs is not supported on this system.' ); 455 } 456 457 update_option( 'medium_crop', 1 ); 458 459 $orig_file = DIR_TESTDATA . '/images/wordpress-gsoc-flyer.pdf'; 460 $test_file = get_temp_dir() . 'wordpress-gsoc-flyer.pdf'; 461 copy( $orig_file, $test_file ); 462 463 $attachment_id = $this->factory->attachment->create_object( 464 $test_file, 0, array( 465 'post_mime_type' => 'application/pdf', 466 ) 467 ); 468 469 $this->assertNotEmpty( $attachment_id ); 470 471 $expected = array( 472 'sizes' => array( 473 'thumbnail' => array( 474 'file' => 'wordpress-gsoc-flyer-pdf-116x150.jpg', 475 'width' => 116, 476 'height' => 150, 477 'mime-type' => 'image/jpeg', 478 ), 479 'medium' => array( 480 'file' => 'wordpress-gsoc-flyer-pdf-300x300.jpg', 481 'width' => 300, 482 'height' => 300, 483 'mime-type' => 'image/jpeg', 484 ), 485 'large' => array( 486 'file' => 'wordpress-gsoc-flyer-pdf-791x1024.jpg', 487 'width' => 791, 488 'height' => 1024, 489 'mime-type' => 'image/jpeg', 490 ), 491 'full' => array( 492 'file' => 'wordpress-gsoc-flyer-pdf.jpg', 493 'width' => 1088, 494 'height' => 1408, 495 'mime-type' => 'image/jpeg', 496 ), 497 ), 498 ); 499 500 $metadata = wp_generate_attachment_metadata( $attachment_id, $test_file ); 501 $this->assertSame( $expected, $metadata ); 502 503 unlink( $test_file ); 504 foreach ( $metadata['sizes'] as $size ) { 505 unlink( get_temp_dir() . $size['file'] ); 506 } 507 } 508 509 /** 447 510 * @ticket 39231 448 511 */
Note: See TracChangeset
for help on using the changeset viewer.