Image thumbnails

Permalink
Hi all,

I am using Community Store with a huge list of products (1047) each with an image. My product lists kept crashing the site which I've worked out is to do with the amount of images that I'm loading in for each product using the memory hogging method of:

<?php 
$imgObj = $product->getImageObj();
if(is_object($imgObj)){
$thumb = $ih->getThumbnail($imgObj,80,80,true);?>


So looking into it further I found (should have been obvious to me) that there is a option to generate thumbnails once instead of the above method generating each load:
https://documentation.concrete5.org/developers/working-with-files-an...

Now what I can't work out is how to have each product pull its image from the thumbnail option noted above.

I have currently tried the following above foreach loop:
$type = \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle('prodimage');


And the following inside the product list foreach loop but it's clear there is nothing that references the products image attribute.

<?php
if (is_object($file)) {
$src = $file->getThumbnailURL($type->getBaseVersion()); ?>
<a class="thumbnail store-product-quick-view" data-product-id="<?= $product->getID()?>" href="#"><img src="<?= $src ?>" class="img-responsive"></a>


Any help would be greatly appreciated.

 
hutman replied on at Permalink Best Answer Reply
hutman
I think you can just do

<?php
$imgObj = $product->getImageObj();
if (is_object($imgObj)) {
$src = $imgObj->getThumbnailURL($type->getBaseVersion()); ?>
<a class="thumbnail store-product-quick-view" data-product-id="<?= $product->getID()?>" href="#"><img src="<?= $src ?>" class="img-responsive"></a>
mobius2000 replied on at Permalink Reply
I think you've nailed hutman... I was so close right before seeing your response but ultimately I had it all wrong.

Thank you so much... Fingers crossed this speeds things up in terms of loading all the images faster than cropping them on the fly.

You're a champion!!!