How to work around missing upload ^^

3 posts by 2 authors in: Forums > CMS Builder
Last Post: November 7, 2009   (RSS)

By avrom - November 1, 2009

Hi guys,

So I'm using the first thumbnail in a series of images, since I don't want to have to load all the images and only need the first one:

<?php foreach ($propertiesRecords as $record): ?>
<?php $upload = $record['photos'][0] ?>

The problem of course is if no images are uploaded then there is an offset error since there is nothing in that field. So how to check if an image is uplaoded in ['photos'][0] so I can replace it with a missing upload images (and not get the offset error).

Thanks !!
Avrom

Re: [virgodesign] How to work around missing upload ^^

By Dave - November 2, 2009

Hi Avrom,

Try this:

<?php $upload = @$record['photos'][0] ?>

<?php if ($upload): ?>
show upload
<?php endif ?>

<?php if (!$upload): ?>
show no upload image
<?php endif ?>


Let me know if that works for you!
Dave Edis - Senior Developer
interactivetools.com