I have a custom template for the page list, which displays the thumbnail image for the page being linked.
I use;
$thumbnail = $page->getAttribute('thumbnail');
$img = Core::make('html/image', array('f' => $thumbnail));
$tag = $img->getTag();
echo $tag;
This works to fetch the full size image which is set as the page thumbnail attribute, but what I’d like to do is be able to return a thumbnail version of that image instead (File Manager Thumbnails (Retina) in this instance, but a larger thumbnail elsewhere).
How do I go about accessing the various sized thumbnails for an image which I retrieve as a page thumbnail attribute?
I tend to do somehting like this
if (is_object($bannerImage)) {
// Code to handle when $bannerImage is set
$thumbTypeHandle = 'tmdBanner'; //some thumb type i created
$type = \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle($thumbTypeHandle);
$src_small = $bannerImage->getThumbnailURL($type->getBaseVersion());
$src_large = $bannerImage->getThumbnailURL($type->getDoubledVersion());
$thumbTypeHandleMob = 'tmdBannerMob'; //some thumb type i created
$typeMob = \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle($thumbTypeHandleMob);
$src_smallMob = $bannerImage->getThumbnailURL($typeMob->getBaseVersion());
$src_largeMob = $bannerImage->getThumbnailURL($typeMob->getDoubledVersion());
}
Then i tend to print out my HTML like this:
<picture>
<source media="(min-width:575px)" srcset="<?= $src_large; ?> 2x, <?= $src_small;?> 1x">
<img src="<?= $src_smallMob; ?>" srcset="<?= $src_largeMob; ?> 2x, <?= $src_smallMob; ?> 1x" alt="<?= $title ?>">
</picture>