Search the Community
Showing results for tags 'imageResize'.
-
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
-
Hello, I've modified the imageResize() function in "images.inc.php" file, so the images are "cut to fit" (I hate the white bands around the images), and also add some PHP GD extra options (desaturate image, apply a watermark through a PNG file, etc.). This "beta" version does these tasks by looking for some parameters in a PHP file included manually in the theme, but this means to change the Prestashop structure (at least the images.inc.php file). I think that the "elegant way" is to make a module in which you can set these tasks for each image type. Here is my question: is there an "official way" to override "images.inc.php". I know that you can override classes, controllers, etc. using the "override" folder. Can I do the same with the "images.inc.php"? Regards.