mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 07:40:07 +00:00
Media: Bail early if image is already the requested size.
In `WP_Image_Editor_Imagick`, bail early in `make_subsize()` if the image is already the requested size. Previously, `make_subsize()` would create another copy of the file. `WP_Image_Editor_GD` doesn't have the same problem. Props wojtekn, danielbachhuber. Fixes #57370. git-svn-id: https://develop.svn.wordpress.org/trunk@55278 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -3770,6 +3770,40 @@ EOF;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that an image size isn't generated if it matches the original image size.
|
||||
*/
|
||||
public function test_wp_generate_attachment_metadata_doesnt_generate_sizes_for_150_square_image() {
|
||||
$temp_dir = get_temp_dir();
|
||||
$file = $temp_dir . '/test-square-150.jpg';
|
||||
copy( DIR_TESTDATA . '/images/test-square-150.jpg', $file );
|
||||
|
||||
$attachment_id = self::factory()->attachment->create_object(
|
||||
array(
|
||||
'post_mime_type' => 'image/jpeg',
|
||||
'file' => $file,
|
||||
)
|
||||
);
|
||||
|
||||
$metadata = wp_generate_attachment_metadata( $attachment_id, $file );
|
||||
$this->assertEquals(
|
||||
array(),
|
||||
$metadata['sizes']
|
||||
);
|
||||
$this->assertEquals(
|
||||
'test-square-150.jpg',
|
||||
basename( $metadata['file'] )
|
||||
);
|
||||
$this->assertEquals(
|
||||
'150',
|
||||
$metadata['width']
|
||||
);
|
||||
$this->assertEquals(
|
||||
'150',
|
||||
$metadata['height']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add threshold to create a `-scaled` output image for testing.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user