5 posts by 3 authors in: Forums > CMS Builder
Last Post: January 12, 2016   (RSS)

Is there a way to setup a default image on a detail page so that if there is not an image for a story the default image shows, then it does not show if my client loads up a specific image.

Thanks for the quick response, I cannot get it to work though, my code for the image is this:

<?php foreach ($latest_newsRecord['image_1_600_x_400'] as $index => $upload): ?>
          <img src="<?php echo htmlencode($upload['urlPath']) ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="<?php echo htmlencode($upload['info1']) ?>" />
        <?php endforeach ?>

By Damon - January 8, 2016

Hi,

Try this code:

<?php foreach ($latest_newsRecord['image_1_600_x_400'] as $index => $upload): ?>
  <img src="<?php echo htmlencode($upload['urlPath']) ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="<?php echo htmlencode($upload['info1']) ?>" />
<?php endforeach ?>

<?php if(!$latest_newsRecord['image_1_600_x_400']) : ?>
   DEFAULT IMAGE: <img src="YOUR DEFAULT IMAGE PATH">
<?php endif; ?>

If the an image hasn't been uploaded for the image, then the code inside the IF statement will be run.

Let me know if you have any questions and if this works for you.

Thanks!

---------------------------------------------------
Cheers,
Damon Edis
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Great, that works perfectly. Thank you very much.