Jump to content

Strange behavior. Upload shop logo in png format, browser show jpg extension, but real in png


sofree

Recommended Posts

Sorry for complicated subject of topic.

I explain.

 

First of all I have an option selected:

(*) Use PNG only if the base image is in PNG format

 

I noted strange behavior.

I posted shop logo in png format.

When I look at source html, link to shop logo looks like /img/logo....jpg.

But, when I open this link to the logo directly in browser, it shows that this image is in png format!

 

I posted an example. Please pay attention on red circles.

 

 

It very surprised me and I became investigating...

 

File

controllers/admin/AdminThemesController.php

			$ext = ($field_name == 'PS_STORES_ICON') ? '.gif' : '.jpg';

apply .jpg extension for ALL uploaded logos, except ICON.

 

So, next, method "resize" from file:

classes/ImageManager.php

tries to recognize file type and looks in configuration (*).

This method does that it does, but final extension already provided...

And we have such strange behavior!

 

My simple solution is write after the above code:

            $tmp_img = getimagesize($tmp_name);
            if (Configuration::get('PS_IMAGE_QUALITY') == 'png_all' || (Configuration::get('PS_IMAGE_QUALITY') == 'png' && $tmp_img[2] == IMAGETYPE_PNG))
                $ext = '.png';

post-826528-0-97441300-1411584990_thumb.png

Edited by sofree (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...