Blog thumbnail - don't show if no image
Permalink
I have a theme which I'm developing, and I have a small but annoying issue with it. Basically I have a hardcoded page list to show blog entries. My problem is that any blog posts that don't have thumbnails are showing them up as a broken image link. I need to use an if statement to only show the image if it exists but I can't figure it out. Code shown below:
<div class="image-link"> <a <?php if ($target != '') { ?> target="<?php echo $target?>" <?php } ?> href="<?php echo $nh->getLinkToCollection($cobj)?>"> <?php $ts = $cobj->getBlocks('Thumbnail Image'); if (is_object($ts[0])) { $tsb = $ts[0]->getInstance(); $thumb = $tsb->getFileObject(); if($thumb){ $imgHelper->outputThumbnail($thumb, 1000, 1000, $title); } } ?> </a> </div>