mirror of
https://github.com/WordPress/WordPress.git
synced 2024-06-28 15:54:57 +02:00
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. Built from https://develop.svn.wordpress.org/branches/5.3@46834 git-svn-id: http://core.svn.wordpress.org/branches/5.3@46634 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
33da7d7e7f
commit
d6875bc495
|
@ -244,6 +244,9 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
|
||||||
$image_meta['image_meta'] = $exif_meta;
|
$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.
|
* Filters the "BIG image" threshold value.
|
||||||
*
|
*
|
||||||
|
@ -256,7 +259,12 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
|
||||||
* @since 5.3.0
|
* @since 5.3.0
|
||||||
*
|
*
|
||||||
* @param int $threshold The threshold value in pixels. Default 2560.
|
* @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 string $file Full path to the uploaded image file.
|
||||||
* @param int $attachment_id Attachment post ID.
|
* @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.
|
// Initial save of the new metadata.
|
||||||
// At this point the file was uploaded and moved to the uploads directory
|
// 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
|
* @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.
|
* @param array $metadata Current attachment metadata.
|
||||||
*/
|
*/
|
||||||
$fallback_sizes = apply_filters( 'fallback_intermediate_image_sizes', $fallback_sizes, $metadata );
|
$fallback_sizes = apply_filters( 'fallback_intermediate_image_sizes', $fallback_sizes, $metadata );
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.3.1-alpha-46833';
|
$wp_version = '5.3.1-alpha-46834';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user