Hello,
Virtuemart, by default, offers a single fixed resolution image resize for thumbnails. Have you (the devs) considered including more variations in the future?
With the use of the <picture> element, one can now define multiple resolutions for an image in the browser.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture
Thanks
VirtueMart has a function to resize the images as per your need.
If you need more resolutions you can adjust your template accordingly. Just check the productdetails view.
You find this in the files:
echo $image->displayMediaThumb("",true,"rel='vm-additional-images'", true, true, false, $width, $height);
Stefan
Hello and thanks.
Does this create additional thumbnails in the images folder?
If so, are they re-used next time, if found by subsequent page loads?
Thanks
They will be in the resized/ folder and will be re-used.
Thanks again.
How can I tweak this code so that I just generate and use the thumbnail filename, but not display it? (VM creates its own img element)
I like to construct my own custom <img /> elements, with additional lazy-loading code and utilizing the <picture> element for image sets.
Hi,
never did it that way, but I guess you could call the function for a variable instead of echo'ing it.
$myhiddenimages = $image->displayMediaThumb(... $width, $height);
The thumbs should be generated then and you can access them by name. As I said, I never tried it. Maybe keep vmdebug on and check the messages and memory usage.
Stefan
Quote from: StefanSTS on September 26, 2018, 18:08:27 PM
Hi,
never did it that way, but I guess you could call the function for a variable instead of echo'ing it.
$myhiddenimages = $image->displayMediaThumb(... $width, $height);
The thumbs should be generated then and you can access them by name. As I said, I never tried it. Maybe keep vmdebug on and check the messages and memory usage.
Stefan
How would I get the filename (and the image URL perhaps) of the generated thumbnail, if I have several variations of them?
Thanks
Just look in the resized folder inside of the images folders for products, categories and so on.
They have an ending according to their size. So it might be: /way/to/images/virtuemart/product/resized/myimage_90x90.jpg
Quote from: EvanGR on October 02, 2018, 08:44:02 AM
How would I get the filename (and the image URL perhaps) of the generated thumbnail, if I have several variations of them?
Thanks
You do not really need it. Just use the function displayMediaThumb and set your desired size and it will be generated on the fly and when it exists already, it will use the already existing one, of course. So you do not need to fuddle around with the different thumbsizes. When you replace or some how change your main media, all thumbs of the media (and maybe some more) will be deleted automatically.
for your lazy load can't u use $imgthumb = JURI::root() . $product->images[0]->getFileUrlThumb();
the function takes sizes as well
function getFileUrlThumb($width = 0,$height = 0)
haven't tried though
Hello,
It seems that displayMediaThumb does not generate new thumbnails when I call it from the template file.
e.g. for testing I am doing this..
$thumbfile = $product->images[0]->displayMediaThumb("",true,"rel='vm-additional-images'", true, true, false, 280, 280);
$thumbfile = $product->images[0]->displayMediaThumb("",true,"rel='vm-additional-images'", true, true, false, 200, 200);
$thumbfile = $product->images[0]->displayMediaThumb("",true,"rel='vm-additional-images'", true, true, false, 160, 160);
Then I look into the product/resized folder, sort files by last created, and do not see any files with the sizes given above.
Any idea?
[VM3.4.2, Dynamic Image Resizing is turned on in the settings]
You do go to tyhe product page where those files are coded to display? The files are generated only when required to display in the frontend. Or am I mis-interpreting what you are trying to do?
The code above is in the product details template file.
There is a problem with my VM setup: the full image sizes are used for product thumbnails. Even though the thumbnails are derived from the /resized/ folder, they are the same size as the original image. And the do not contain any dimensions appended to the filename (e.g. _280x280.jpg).
I am trying to troubleshoot this. Which is why I tried to force the creation of custom thumbnails with the previous code. But that does not work either.
Something broke along the way, and I don't know what.
Note: The /resized/ folder does contain a lot of properly generated thumbnails, but it may be from previous products on earlier VM installations. The current version of VM (3.4 on my test site) does not seem to generate resized thumbnails for me!
Quote from: EvanGR on January 20, 2019, 09:57:13 AM
The code above is in the product details template file.
There is a problem with my VM setup: the full image sizes are used for product thumbnails. Even though the thumbnails are derived from the /resized/ folder, they are the same size as the original image. And the do not contain any dimensions appended to the filename (e.g. _280x280.jpg).
I am trying to troubleshoot this. Which is why I tried to force the creation of custom thumbnails with the previous code. But that does not work either.
Something broke along the way, and I don't know what.
Note: The /resized/ folder does contain a lot of properly generated thumbnails, but it may be from previous products on earlier VM installations. The current version of VM (3.4 on my test site) does not seem to generate resized thumbnails for me!
I believe thumbnail creation needs "gd library" enabled. Is it enabled on your installation?
Yes, GD is installed. I think the problem may be with the specific VM version... I am opening a new thread about this issue...