Insert "no_image.gif" when no image is uploaded

3 posts by 2 authors in: Forums > CMS Builder
Last Post: October 3, 2008   (RSS)

By kovali - October 2, 2008

Hi all,

I want to insert a "no_image.gif" in a products list for a specific product, only in case no picture was uploaded for a that product. Is this possible pls?

My code for now (works fine, but shows a blank space where no picture is available...) :

<?php foreach ($record['foto'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<a href="<?php echo $upload['urlPath'] ?>" class="highslide" onClick="return hs.expand(this, {captionId: 'caption1'})"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" border="0"/></a><br/>


<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>


<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>


<?php endif ?>
<?php endforeach ?>


Thanks !!

Re: [kovali] Insert "no_image.gif" when no image is uploaded

By Dave - October 2, 2008

Hi Kovali, Welcome to the CMS Builder forum!

Just add this after the <?php endforeach ?>

<?php if (!$record['foto']): ?>
Sorry, no images. <img ... your tag here ... />
<?php endif ?>

The ! means "not" as in "not images" or "no images".

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com