mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
Preserve PNG transparency/alpha during thumbnail creation. Fixes #2805 props Libertus/Otto42.
git-svn-id: http://svn.automattic.com/wordpress/trunk@6439 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
71b2207ea3
commit
92c4835150
@ -33,6 +33,13 @@ function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) {
|
|||||||
list($image_new_width, $image_new_height) = wp_shrink_dimensions( $sourceImageWidth, $sourceImageHeight, $max_side, $max_side);
|
list($image_new_width, $image_new_height) = wp_shrink_dimensions( $sourceImageWidth, $sourceImageHeight, $max_side, $max_side);
|
||||||
|
|
||||||
$thumbnail = imagecreatetruecolor( $image_new_width, $image_new_height);
|
$thumbnail = imagecreatetruecolor( $image_new_width, $image_new_height);
|
||||||
|
|
||||||
|
// preserve PNG transparency
|
||||||
|
if( IMAGETYPE_PNG == $sourceImageType && function_exists( 'imagealphablending' ) && function_exists( 'imagesavealpha' )) {
|
||||||
|
imagealphablending($thumbnail, false);
|
||||||
|
imagesavealpha($thumbnail,true);
|
||||||
|
}
|
||||||
|
|
||||||
@ imagecopyresampled( $thumbnail, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $sourceImageWidth, $sourceImageHeight );
|
@ imagecopyresampled( $thumbnail, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $sourceImageWidth, $sourceImageHeight );
|
||||||
|
|
||||||
imagedestroy( $image ); // Free up memory
|
imagedestroy( $image ); // Free up memory
|
||||||
|
Loading…
Reference in New Issue
Block a user