Is there a way to convert automatically uploaded PNGs to JPEGs and keep the original? In other words, let the user upload a PNG, but show in wordpress (thumbnails, large, medium, etc) the JPEG version and only show the original uploaded PNG when WordPress request the full image.

1 Answer
1

There is a way, I recommend you combine the imagefx plugin with a custom function , http://wordpress.org/extend/plugins/imagefx/

You can read about it here: http://ottopress.com/tag/gd/ , and use a function like one found here: https://stackoverflow.com/questions/1201798/use-php-to-convert-png-to-jpg-with-compression

It would look something like (not tested):

imagefx_register_filter('custom-name','my_custom_filter');

function my_custom_filter(&$image, $outputFile, $quality) {
$image = imagecreatefrompng(&$image);
imagejpeg($image, $outputFile, $quality);
imagedestroy($image);

}

But remember they are not the same format and .jpg does doesn’t support alpha-transparency

Leave a Reply

Your email address will not be published. Required fields are marked *