DISPLAYING A GENERIC IMAGE OR SPECIAL TEXT IF NO IMAGE IS UPLOADED - Aug 3rd, 2010


A number of users have asked how to display a generic image (or specific text) if no image has been uploaded to a
record. Well there are a number of ways. One offered by Dave Edis from Interactive Tools is:



<?php foreach ($your_tableRecords as $record): ?>

<?php if (sizeof($record['your_image_field']) >= 1): ?>

<?php foreach ($record[‘your_image_field'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<a href="<?php echo $record['_link'] ?>"><img src="<?php echo $upload['thumbUrlPath'] ?>" alt="" width="<?php
echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" align="center" /></a>
<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" alt="" width="<?php echo $upload['width'] ?>" height="<?php echo
$upload['height'] ?>" align="right" />
<?php endif ?>
<?php endforeach ?>

<?php else: ?>
<img src="http://www.your_site.com/path_to_your_generic_image/generic_image.jpg" width="your_image_width_in_pixels"
height="your_image_height_in_pixels" alt="your_alt_text" />
<?php endif ?>
<?php endforeach; ?>




The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service