Jump to content

Upload product images for fancybox with width and height set to 0 in preferences


tanilo

Recommended Posts

Hi all,

I'm just starting using Prestashop, and for each product in my site I would like to show a gallery of pictures.

I see that Prestashop use fancybox as default, and it's ok for me... but every picture shown was square with empty white space.

I didn't like it.. I wanted to see my rectangular pictures (with that cool effect of resizing when you're browsing throw the gallery).

After some search I found out that I can decide the size of the picture in Preferences->Image tab, where you can decide the size of some picture categories: small, medium, large, thickbox, category, home, large_scene, thumb_scene.

 

I just set width and height to 0 for thickbox category, and then I rebuilt the thumbnails, and after this my gallery was shown as I wanted... with my rectangular pictures.

 

But after thet, if I tried to add a new picture to a product i received an error: An error occurred while copying image: thickbox.

 

Of course some functions didn't like new size 0x0. And if I tried to see the gallery, I just received an error while I was showing picture I just uploaded.

But after Preferences->Image->rebuilt the thumbnails.. everything worked again.

 

So there is something wrong during upload... I just had a look into the code and found that in

/prestashop/admin/tabs/AdminProducts.php, function copyImage call function imageResize and after that the error is displayed.

 

Function imageResize is in /prestashop/images.inc.php... I just changed rows

 

 

if ($destWidth == NULL) $destWidth = $sourceWidth;

if ($destHeight == NULL) $destHeight = $sourceHeight;

 

in

 

 

if ($destWidth == NULL || $destWidth == 0) $destWidth = $sourceWidth;

if ($destHeight == NULL || $destHeight == 0) $destHeight = $sourceHeight;

[is this a bug?]

 

and after this also upload pictures worked with no errors... but with a side effect:

-if I upload a picture too big, it's not resized to fit the screen.

 

I just looked in /prestashop/js/jquery/jquery.fancybox-1.3.4.js and I saw that default values was:

 

[snip]

 

autoScale : false,

autoDimensions : false,

[snip]

[is this a bug?]

 

But I didn't want to change these settings because these changes will affect the whole site and i don't know if there be some problem (I think not.. anyway).

I just search the javascript file where fancybox is initialized, and it's:

/prestashop/themes/prestashop/js/product.js

I'm using default theme with prestashop 1.4, and this is the only file where fancybox is initialized, and it's only for products... so it's ok for me to change it from:

 

 

$('.thickbox').fancybox({

'hideOnContentClick': true,

'transitionIn' : 'elastic',

'transitionOut' : 'elastic'

});

 

to

 

 

$('.thickbox').fancybox({

'autoScale': true,

'autoDimensions': true,

 

'hideOnContentClick': true,

'transitionIn' : 'elastic',

'transitionOut' : 'elastic'

});

 

And after these changes, even if uploaded image is too big, it's resized to fit the screen.

 

 

This is all I done to make the fancybox gallery work the way I like it... I wrote everything just because I'm new of prestashop, and I don't know if what I did is the right way to work.. and if what I found is to be considered a bug or not.

 

Hope this can help someone,

bye,

 

tan

 

ps. sorry for my english :-P

  • Like 4
Link to comment
Share on other sites

  • 1 month later...
  • 4 years 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...