News:

Looking for documentation? Take a look on our wiki

Main Menu

how to display cropped product images as thumbnails

Started by dorex, November 28, 2012, 10:37:07 AM

Previous topic - Next topic

dorex

Hi everyone,
I want to display products thumbnails as cropped images from the full size products images. I mean that a thumbnail should be a close-up of the full image.
If I have a full size image of 200x400 px, than the thumbnail should be generated for the square upper side area of 200x200 px.

Any ideas how can this be done in Virtuemart 2.0.14 ?
I found another similar topic in VM 1.1 forum, but the problem has never been solved: http://forum.virtuemart.net/index.php?topic=84423.0

Thank you in advance for any help.
PHP 5.2.17 - Joomla 2.5.8 - Virtuemart 2.0.16

bytelord

Hello,

You will need PHP knowledge about that to create it, can be done by editing the mediahandler, the thumbnail creation part, but this may affect o site performance.
The file that is responsible for that is located under administrator\components\com_virtuemart\helpers\img2thumb.php ... you can study the file

You can find some code over the web, never tested, and adjust the file:

http://jueseph.com/2010/06/opticrop-content-aware-cropping-with-php-and-imagemagick/
http://911-need-code-help.blogspot.gr/2009/04/crop-to-fit-image-using-aspphp.html
http://www.codediesel.com/php/easy-thumbnail-generation-using-php/
http://snipplr.com/view/41867/

use google to find more...

Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

dorex

Quote from: bytelord on November 28, 2012, 14:52:04 PM
You will need PHP knowledge about that to create it, can be done by editing the mediahandler, the thumbnail creation part, but this may affect o site performance.

Hi, Bytelord,

Thank you for answering, but if this is the case, this solution is going to wait for now ... since I have to finish this work next week.

But I'm having another question, now :)  I've thought to a roundabout solution and the obvious one that came up would be to edit and upload the custom thumbnails myself (all at the same size, keeping the automatic generated names by VM) and just replace the ones generated by Virtuemart. This one shouldn't be hard at all, but I'm new to VM and I'm not used to it (I wanted to try it while there was not a stable version release yet, and at that time nobody seemed to know very much and everyone was busy working on it. I was in a hurry and used another extension, but their lack of options made me come back .... so here I am again :D ). Thank you.
PHP 5.2.17 - Joomla 2.5.8 - Virtuemart 2.0.16

dorex

I figured this one myself and it works.

For the product with the full size image here:        /images/stories/virtuemart/product/hammer.jpg
VM automaticaly creates a thumbnail here:      /images/stories/virtuemart/product/resized/hammer_90x90.jpg

One should only go to folder:   /images/stories/virtuemart/product/resized/

and replace automatically generated thumbnail  "hammer_90x90.jpg"   with a customized thumbnail  "hammer_90x90.jpg"

Hope this helps another beginner like myself.

All the best!
PHP 5.2.17 - Joomla 2.5.8 - Virtuemart 2.0.16

bytelord

oh!

I was thinking you wanna create a new function to crop images so have the same width and height. :)

Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!