Upload: Exclude PNG images from scaling after uploading. Fixes a case where resizing a very large PNG may create a scaled image that has smaller dimensions but larger file size than the original.
Props azaozz. Merges [46809] to the 5.3 branch. Fixes #48736. git-svn-id: https://develop.svn.wordpress.org/branches/5.3@46834 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f5afff0560
commit
e53dc246dc
@ -244,6 +244,9 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
|
||||
$image_meta['image_meta'] = $exif_meta;
|
||||
}
|
||||
|
||||
// Do not scale (large) PNG images. May result in sub-sizes that have greater file size than the original. See #48736.
|
||||
if ( $imagesize['mime'] !== 'image/png' ) {
|
||||
|
||||
/**
|
||||
* Filters the "BIG image" threshold value.
|
||||
*
|
||||
@ -256,7 +259,12 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
|
||||
* @since 5.3.0
|
||||
*
|
||||
* @param int $threshold The threshold value in pixels. Default 2560.
|
||||
* @param array $imagesize Indexed array of the image width and height (in that order).
|
||||
* @param array $imagesize {
|
||||
* Indexed array of the image width and height in pixels.
|
||||
*
|
||||
* @type int $0 The image width.
|
||||
* @type int $1 The image height.
|
||||
* }
|
||||
* @param string $file Full path to the uploaded image file.
|
||||
* @param int $attachment_id Attachment post ID.
|
||||
*/
|
||||
@ -329,6 +337,7 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Initial save of the new metadata.
|
||||
// At this point the file was uploaded and moved to the uploads directory
|
||||
@ -541,7 +550,7 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
|
||||
*
|
||||
* @since 4.7.0
|
||||
*
|
||||
* @param array $fallback_sizes An array of image size names.
|
||||
* @param string[] $fallback_sizes An array of image size names.
|
||||
* @param array $metadata Current attachment metadata.
|
||||
*/
|
||||
$fallback_sizes = apply_filters( 'fallback_intermediate_image_sizes', $fallback_sizes, $metadata );
|
||||
|
Loading…
Reference in New Issue
Block a user