Login | Sign up | Toll-Free: 1-800-752-0455
 
 

Forum

 

5 posts by 3 authors in: Forums > CMS Builder
Last Post: January 12, 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.

Hi there.

Thanks for posting.

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

<?php  if (!$record['image']): ?>
<img src="YOUR DEFAULT IMAGE PATH">
<?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.

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

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: http://www.interactivetools.com/consulting/

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 ?>

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.