Jump to content

Upload Gif Or Png Images For Header Logo


KostasX

Recommended Posts

With a minor change you can upload png or gif images with transparency directly from the Preferences->Appearance.

All you have to do is edit adminFolder/tabs/AdminPreferences.php

and find the lines for image save process.

 

I will show you the code for PS_LOGO and you can do the same for PS_LOGO_MAIL and PS_LOGO_INVOICE.

 

This was tested in 1.4.6.2 and don't know if it works for other versions, but it should work for most 1.4 versions.

 

So, in line 259 you have to change this code:

if (isset($_FILES['PS_LOGO']['tmp_name']) AND $_FILES['PS_LOGO']['tmp_name'])
{
 if ($error = checkImage($_FILES['PS_LOGO'], 300000))
$this->_errors[] = $error;
 if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') OR !move_uploaded_file($_FILES['PS_LOGO']['tmp_name'], $tmpName))
return false;
 elseif (!@imageResize($tmpName, _PS_IMG_DIR_.'logo.jpg'))
$this->_errors[] = 'an error occurred during logo copy';
 unlink($tmpName);
}

 

into this:

if (isset($_FILES['PS_LOGO']['tmp_name']) AND $_FILES['PS_LOGO']['tmp_name'])
{
 $tmp = explode('/',$_FILES['PS_LOGO']['type']);	// Add these two lines to get
 $extension = count($tmp) == 2 ? $tmp[1] : 'jpg';   // the image type
 if ($error = checkImage($_FILES['PS_LOGO'], 300000))
$this->_errors[] = $error;
 if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') OR !move_uploaded_file($_FILES['PS_LOGO']['tmp_name'], $tmpName))
return false;
 elseif (!@imageResize($tmpName, _PS_IMG_DIR_.'logo.jpg',NULL,NULL,$extension)) //and pass it to imageResize to create the file accordingly
$this->_errors[] = 'an error occurred during logo copy';
 unlink($tmpName);
}

 

Actually the changes are these 2 lines you have to add in the beginning of the if statement

 $tmp = explode('/',$_FILES['PS_LOGO']['type']);
 $extension = count($tmp) == 2 ? $tmp[1] : 'jpg';

 

and the alteration of this line

 elseif (!@imageResize($tmpName, _PS_IMG_DIR_.'logo.jpg'))

 

to this

 elseif (!@imageResize($tmpName, _PS_IMG_DIR_.'logo.jpg',NULL,NULL,$extension))

 

You can change also the next 2 if statements for PS_LOGO_MAIL and PS_LOGO_INVOICE exactly the same way.

 

I hope you 'll find it helpfull.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

@Kostas

I feel really dumb for this post. :(

 

There is an option for uploading PNG images in Preferences -> Images -> Use PNG only if the base image is in PNG format.

 

I reinvented the wheel !!! Good for ME :P

 

You still were of such great help. I followed everything from your first post all the way down just to find the simpler route on your last post, i'l start reading through before practicing anything now :ph34r:

 

http://www.jambo254.com/

Link to comment
Share on other sites

  • 1 month later...

I am sorry, but this also doesn´t work. When I change option to "use PNG..." nothing happens - pngs are still not transparent....

v.1.4.7

 

Do you upload PNG images with transparency?

This work only if the images you uploaded have already transparent background.

Link to comment
Share on other sites

  • 3 months later...

I feel really dumb for this post. :(

 

There is an option for uploading PNG images in Preferences -> Images -> Use PNG only if the base image is in PNG format.

 

I reinvented the wheel !!! Good for ME :P

 

lol. You may have reinvented the wheel but thanks a lot for posting both those solutions! :) Was helpful.

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

  • 3 years later...

Hi,

sigh..  :(  still looking for "animated-gif-as-logo" for my: www.moratospain.es

Prestashop 1.6.1.4

 

TIll now I did:

- I uploaded via FileZilla: moratospain.es/img/fashion-barcelona-logo-1460114402.gif

  (img folder): the animated gif is only 48Kb and works fine.

- I changed the header.tpl (themes folder)

from:

src="{$logo_url}"  

to:

src="/{$img_ps_dir}fashion-barcelona-logo-1460114402.gif?"

 

from:

<img class="logo img-responsive" src="{$logo_url}" alt="{$shop_name|escape:'html':'UTF-8'}"{if isset($logo_image_width) && $logo_image_width} width="{$logo_image_width}"{/if}{if isset($logo_image_height) && $logo_image_height} height="{$logo_image_height}"{/if}/>

 

  to:

<img class="logo img-responsive" src="/{$img_ps_dir}fashion-barcelona-logo-1460114402.gif?" alt="{$shop_name|escape:'html':'UTF-8'}"{if isset($logo_image_width) && $logo_image_width} width="{$logo_image_width}"{/if}{if

isset($logo_image_height) && $logo_image_height} height="{$logo_image_height}"{/if}/>

 

..but it doesn't WORK !! :wacko:

What did I miss ?!!  :(

Paolo

Link to comment
Share on other sites

  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...