Display Default Img if None Uploaded

2 posts by 2 authors in: Forums > CMS Builder
Last Post: February 2, 2010   (RSS)

Hi there,

How do I display a default image in a list if no thumbnail is available? Here is my code:

<?php foreach ($record['property_photos'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<a href="<?php echo $record['_link'] ?>"><img src="<?php echo $upload['thumbUrlPath2'] ?>" width="<?php echo $upload['thumbWidth2'] ?>" height="<?php echo $upload['thumbHeight2'] ?>" alt="<?php echo $record['heading'] ?>" /></a>
<?php else: ?>
<img src="library/img/default-investment.gif" width="150" height="100" alt="<?php echo $record['heading'] ?>" />

<?php endif ?>
<?php break; ?>
<?php endforeach ?>


Many thanks!