5.7.4.2 Get thumbnail from page?
Permalink
The code changed for most blocks in 4-2 and I need a way to fetch the image block from one of my pages again.
Because it's an old site I would rather not reinvent the wheel as my client knows how to do things a certain way.
This is the area on the site which I need to grab the thumbnail from and to achieve this my custom block used an image helper:
Now apparently this has all changed and the thumbnail is an attribute. How would I get the thumbnail now?
Because it's an old site I would rather not reinvent the wheel as my client knows how to do things a certain way.
<div id="thumbnail">
<?php
if ($c->isEditMode()) {
print '<br><br>';
$a = new Area('Thumbnail Image');
$a->display($c);
}
?>
</div>This is the area on the site which I need to grab the thumbnail from and to achieve this my custom block used an image helper:
<div class="image-link">
<a <?php if ($target != '') { ?> target="<?php echo $target ?>" <?php } ?> href="<?php echo $url ?>">
<?php
$ts = $page->getBlocks('Thumbnail Image');
if (is_object($ts[0])) {
$tsb = $ts[0]->getInstance();
$thumb = $tsb->getFileObject();
if ($thumb) {
$ih->outputThumbnail($thumb, 170, 80, $title);
}
}
?>
</a>
</div>Now apparently this has all changed and the thumbnail is an attribute. How would I get the thumbnail now?
<div class="image-link"> <a <?php if ($target != '') { ?> target="<?php echo $target ?>" <?php } ?> href="<?php echo $url ?>"> <?php foreach ($blocks as $block) { if ($block->getBlockTypeHandle() == "image" && $block->getAreaHandle() == "Thumbnail Image") { if (is_object($block)) { $tsb = $block->getInstance(); $thumb = $tsb->getFileObject(); if ($thumb) { $ih->outputThumbnail($thumb, 170, 80); } } } } ?>