adhd_kid Posted November 12, 2012 Share Posted November 12, 2012 (edited) Hey guys, recently i've done 2 Prestashop templates that needed the zoom-crop functionality for certain image types ( see timthumb to know what i mean) . My first approach (it was Presta 1.4.x) was to override the The admin tabs and do lots of unneccessary stuff, then the other project came and when i was about to copy my old code i thought of a much better solution, so here it is : 0. Read our short introduction and copy code from here: http://www.bazingade...restashop-1-5-2 or here (without introduction): http://pastebin.com/eg2tLztL 1. Go to Preferences -> Images -> Add new and set the new image size that you want to be zoom-cropped (to fit the whole area) 2. Name the new image size adding the "_btt" suffix to it 3. regenerate your pictures, use the new picture name in your templates where neccessary and enjoy *** In the attachment you will find an example of how should new image size with crop be named in the backoffice **** Remember to actually use the new image size in your templates, like: <img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'fbmag_btt')}" > Edited November 15, 2012 by adhd_kid (see edit history) 1 Link to comment Share on other sites More sharing options...
Vinc3nzo Posted November 15, 2012 Share Posted November 15, 2012 (edited) hi! sorry, no work for me, PS1.5.2 You have exemple for configuration image size please? i have write Preferences -> Images -> Add new and set the new image size 600x600 and name "cropsmall_btt"... and I have been save correctly in /overrides/classes/ImageManager.php and regenerate all thumbs... :/ Edited November 15, 2012 by Vinc3nzo (see edit history) Link to comment Share on other sites More sharing options...
adhd_kid Posted November 15, 2012 Author Share Posted November 15, 2012 Ok Vinc3nzo, i updated the first post with an image example (ps have you used the new name of the file size in your template?) 1 Link to comment Share on other sites More sharing options...
Vinc3nzo Posted November 20, 2012 Share Posted November 20, 2012 (edited) Hello, I still do not understand how to use your wits. I change my files. TPL "home_default" and that's it foncitonne wrong, I do not understand the order of manipulations ... What exactly TPL file must be modified? Can disable after "home_default"? or we are obliged to leave? The pictures do not cut the product details on the "THUMBS" on mouseover ... :/ Thx you advance! good continuation! PS: i have multiple image dimension... Edited November 20, 2012 by Vinc3nzo (see edit history) Link to comment Share on other sites More sharing options...
petete2008 Posted November 21, 2012 Share Posted November 21, 2012 Thanks for sharing Link to comment Share on other sites More sharing options...
adhd_kid Posted November 22, 2012 Author Share Posted November 22, 2012 Hi Vincenzo, I just think that what you need to do is simple but you need a bit of further explanation. Tomorrow i should be having my day off from work so mail me: [email protected] and i'll see what your page outputs then will tell you what to do exactly so you can write this in your own words for others who might not understand what they need to do here, ok? Hello, I still do not understand how to use your wits. I change my files. TPL "home_default" and that's it foncitonne wrong, I do not understand the order of manipulations ... What exactly TPL file must be modified? Can disable after "home_default"? or we are obliged to leave? The pictures do not cut the product details on the "THUMBS" on mouseover ... :/ Thx you advance! good continuation! PS: i have multiple image dimension... Link to comment Share on other sites More sharing options...
nostradamus Posted December 10, 2012 Share Posted December 10, 2012 when i replace the file wiht the one u suggested i get a white page when i want to regenerate the images Link to comment Share on other sites More sharing options...
elvispl Posted December 19, 2012 Share Posted December 19, 2012 Or... in ImageManager.php repleace: if (Configuration::get('PS_IMAGE_GENERATION_METHOD') == 2 || (!Configuration::get('PS_IMAGE_GENERATION_METHOD') && $width_diff > $height_diff)) to: if (Configuration::get('PS_IMAGE_GENERATION_METHOD') == 2 || (!Configuration::get('PS_IMAGE_GENERATION_METHOD') && $width_diff < $height_diff)) works on 1.5.2 2 Link to comment Share on other sites More sharing options...
samychamba Posted January 12, 2013 Share Posted January 12, 2013 Or... in ImageManager.php repleace: if (Configuration::get('PS_IMAGE_GENERATION_METHOD') == 2 || (!Configuration::get('PS_IMAGE_GENERATION_METHOD') && $width_diff > $height_diff)) to: if (Configuration::get('PS_IMAGE_GENERATION_METHOD') == 2 || (!Configuration::get('PS_IMAGE_GENERATION_METHOD') && $width_diff < $height_diff)) works on 1.5.2 +10 1 Link to comment Share on other sites More sharing options...
mlis82 Posted August 1, 2013 Share Posted August 1, 2013 Any update? Link to comment Share on other sites More sharing options...
adhd_kid Posted August 1, 2013 Author Share Posted August 1, 2013 Any update? Mlis82 I've been using this piece of code throughout all the versions of Prestashop 1.5.x and it always works (either starting with a fresh installation or updating an existing one). Link to comment Share on other sites More sharing options...
mlis82 Posted August 1, 2013 Share Posted August 1, 2013 I've just changed code like elvispl said and now it's work fine. Best Regards This pice of code is great:) Thank You a Lot Link to comment Share on other sites More sharing options...
jbenmouhar Posted October 29, 2013 Share Posted October 29, 2013 Hi, must be put "ImageManager.php" file in "overrides/classes" or "override/classes /"? I tested the two but nothing works my file image name "test_btt" prestashop 1.5.5.0 Link to comment Share on other sites More sharing options...
tomasz_be Posted November 14, 2013 Share Posted November 14, 2013 Works great with 1.5.6. Thanks! Link to comment Share on other sites More sharing options...
nev Posted February 22, 2014 Share Posted February 22, 2014 This is awesome! It's such a great solution and really simple to do. Thanks adhd_kid!:) For those people out there that were struggling like me, wondering why it didn't work at first, it's probably as simple as deleting the cashe/class_index.php file. Link to comment Share on other sites More sharing options...
Martin-F Posted July 23, 2014 Share Posted July 23, 2014 ¡¡ Works perfectly with ps 1.5.4.1 !!One question: Is it possible to modify the code in order to move a little bit (percent) the cropping to one side (left or right)???Excellent contribution.Thanks. Link to comment Share on other sites More sharing options...
adhd_kid Posted July 24, 2014 Author Share Posted July 24, 2014 @martinf you see this should not be a big task: the zoom-crop code is taken directly from Timthumb and all current versions of that script contain a number of ways you can crop the image (crop to left, right, bottom, top), so the only thing to do would be to paste the missing code and create additional conditions somewhere after the _btt suffix such as "_btt_l" (for zoop-crop left) or "_btt_r" for zoom-crop right :-) Link to comment Share on other sites More sharing options...
dromansab Posted July 31, 2014 Share Posted July 31, 2014 (edited) Hi, I've replaced the code from classes/ImageManager.php and It doesn't work form me.. When I try to regenerate images, there is a fatal error Fatal error: Class 'ImageManagerCore' not found in /usr/home/../../classes/ImageManager.php on line 18 I'm using 1.5.6.2 version. Could somebody help me? Thanks! Edited July 31, 2014 by dromansab (see edit history) Link to comment Share on other sites More sharing options...
adhd_kid Posted July 31, 2014 Author Share Posted July 31, 2014 @dromansab are you sure you put the code into /overrides/classes/ImageManager.php ? If you replaced the /classes/ImageManager.php then you need to bring it back After you've done everything be sure to delete this file: /cache/class_index.php to make Prestashop aware of the changes. Link to comment Share on other sites More sharing options...
dromansab Posted July 31, 2014 Share Posted July 31, 2014 It works! I overwrote the original file.. Thanks! Link to comment Share on other sites More sharing options...
kamiliok Posted August 21, 2014 Share Posted August 21, 2014 Saved my day! Or...in ImageManager.phprepleace: if (Configuration::get('PS_IMAGE_GENERATION_METHOD') == 2 || (!Configuration::get('PS_IMAGE_GENERATION_METHOD') && $width_diff > $height_diff)) to: if (Configuration::get('PS_IMAGE_GENERATION_METHOD') == 2 || (!Configuration::get('PS_IMAGE_GENERATION_METHOD') && $width_diff < $height_diff)) works on 1.5.2 Thanks! That works on 1.6 to. 1 Link to comment Share on other sites More sharing options...
lchavee Posted January 20, 2015 Share Posted January 20, 2015 Hello, It works for Prestashop 1.6.0.9, But I've got an error when I go to the product list in the BO. Unknow error à la ligne 152 du fichier /home/www/override/classes/ImageManager.php [2048] Declaration of ImageManager::resize() should be compatible with ImageManagerCore::resize($src_file, $dst_file, $dst_width = NULL, $dst_height = NULL, $file_type = 'jpg', $force_type = false, &$error = 0) Do you know what could be the issue ? Thanks Link to comment Share on other sites More sharing options...
Aminta Posted February 9, 2015 Share Posted February 9, 2015 Hi, here's the function adapted for PS 1.6, replace all the code in "classes/ImageManager.php" http://pastebin.com/3Hsk9s1e 1 Link to comment Share on other sites More sharing options...
YanK Posted February 10, 2015 Share Posted February 10, 2015 My file ImageManager.php.zip : use "_crop" With this file native class used for other images. Just used for image with "_crop" name. 2 Link to comment Share on other sites More sharing options...
Gab Posted March 19, 2015 Share Posted March 19, 2015 Merci Yank, ca fonctionne à merveille Dingue que ça ne soit toujours pas natif dans Prestashop... 1 Link to comment Share on other sites More sharing options...
PrestaMathieu Posted October 8, 2015 Share Posted October 8, 2015 (edited) Hi,It's really Great. It's work good with Presta 1.6.1.1do you know if it's possible to crop with specific X et Y coordonate ? [edit] it's in order to crop on the right of the picture and no in the center (default beahvior)Thanks Edited October 8, 2015 by PrestaMathieu (see edit history) Link to comment Share on other sites More sharing options...
PrestaMathieu Posted October 12, 2015 Share Posted October 12, 2015 (edited) mini up... noboby have a solution for crop the right of the image and no the center ? Edited October 12, 2015 by PrestaMathieu (see edit history) Link to comment Share on other sites More sharing options...
babyewok Posted November 27, 2015 Share Posted November 27, 2015 This all works great it 1.6.1.1 What I need now is an additional image resize method for thickbox images whereby prestashop does not resize images below the set image size. ie it doesn't add the white border if the image is smaller, it just leaves it, but does resize images that are larger. How can I do that? Link to comment Share on other sites More sharing options...
babyewok Posted January 12, 2016 Share Posted January 12, 2016 (edited) Hello, It works for Prestashop 1.6.0.9, But I've got an error when I go to the product list in the BO. Unknow error à la ligne 152 du fichier /home/www/override/classes/ImageManager.php [2048] Declaration of ImageManager::resize() should be compatible with ImageManagerCore::resize($src_file, $dst_file, $dst_width = NULL, $dst_height = NULL, $file_type = 'jpg', $force_type = false, &$error = 0) Do you know what could be the issue ? Thanks Having the same issue - the error only shows though if I hhave developer mode set to true - any solutions?? The image resize all works fine, just get theis error in dev mode EDIT: Solved this issue (in 1.6.1.1) by changing the first line of the override to: public static function resize($src_file, $dst_file, $dst_width = null, $dst_height = null, $file_type = 'jpg', $force_type = false, &$error = 0, &$tgt_width = null, &$tgt_height = null, $quality = 5, &$src_width = null, &$src_height = null) Edited January 12, 2016 by babyewok (see edit history) Link to comment Share on other sites More sharing options...
david_robert Posted June 23, 2016 Share Posted June 23, 2016 Thanks Yank, it works great for the 1.6.1.5 version Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now