Default image on detail page

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

By MercerDesign - January 7, 2016

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.

By ross - January 7, 2016

Hi there.

Thanks for posting.

Here's what I would do to have a default image if nothing was uploaded:

<?php  if (!$record['image']): ?>
<?php endif ?>

Then, before that, you can put the code generator code for displaying images. If there is an image uploaded, that will trigger the code generator code you copied over.  If there is no image uploaded, the code generator code will not run but this new block of code will.

Give that shot and let me know any questions or feedback.


Ross Fairbairn - Consulting

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting:

By Damon - January 8, 2016


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']) : ?>
<?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.


Damon Edis -

Hire me! Save time by getting our experts to help with your project.

By MercerDesign - January 12, 2016

Great, that works perfectly. Thank you very much.