hey, the User Photo plugin doesn’t handle transparency. If you want you can modify the code a little.
here is what you need to do(User Photo ver. 0.9.5.1)
code taken from: http://ww.wp.xz.cn/support/topic/plugin-user-photo-transparent-png-support?replies=4
- open “user-photo.php”
-
find line 899
elseif ( $info[2] == IMAGETYPE_PNG ) {
if (!imagepng( $imageresized, $newFilename ) ) {
$error = __( "Thumbnail path invalid" );
}
}
- change it to
elseif ( $info[2] == IMAGETYPE_PNG ) {
@ imageantialias($imageresized,true);
@ imagealphablending($imageresized, false);
@ imagesavealpha($imageresized,true);
$transparent = imagecolorallocatealpha($imageresized, 255, 255, 255, 0);
for($x=0;$x<$image_new_width;$x++) {
for($y=0;$y<$image_new_height;$y++) {
@ imagesetpixel( $imageresized, $x, $y, $transparent );
}
}
@ imagecopyresampled( $imageresized, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $info[0], $info[1] );
if (!imagepng( $imageresized, $newFilename ) ) {
$error = __( "Thumbnail path invalid" );
}
}
- Upload your photo again
Thanks a lot, but it doesn’t really work.
Now it doesn’t upload the photo at all.
I’ll just tell the client to make sure the image has a white background.
Do you know if it supports transparent GIF from standard?
Thx. This code worked perfectly for me.
I can upload PNG’s whith transparent background.