Test for image upload first

3 posts by 2 authors in: Forums > CMS Builder
Last Post: April 11, 2012   (RSS)

By furcat - March 29, 2012

I am using code shown below where I have a section editor/page where I allow my customer to upload multiple images for a page.

<h3>Additional Photos</h3>
<p>Click on a thumbnail shown below for a larger image.</p>
<?php foreach ($ecofuelRecord['additional_photos'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<a href="<?php echo $upload['urlPath'] ?>"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /></a>&nbsp;&nbsp;

<?php else: ?>
<h3>No photos for this page</h3>

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


However, I would like to test first to see if an image has actually been uploaded before I put the text about "Additional Photos" on the page. I don't like the way it looks to have a heading about additional items if none in fact exist.

So, how do I test to see if an image has been uploaded before the foreach statement?

Thanks!

Re: [rconring] Test for image upload first

By furcat - April 11, 2012

Perfect. Exactly what I needed. Thank you.