I have a gallery page for each user who has a profile on my site. I want the gallery to pull images from the database and use them in the appropriate places - I have this working. But when there are no images to display I want to display five blocks with an 'images coming soon' placeholder.
How can I adapt the following PHP code to show the placeholders if the foreach array is empty? At present if no images exist in the DB nothing is shown in the gallery space.
<?php foreach($galleryphotos as $galleryphoto): ?>
<?php if(!empty($galleryphoto['galleryphoto_file'])){ ?>
<div class="csmx-gallery-item csmx-isotope-item col-xs-12 col-sm-6 grid-sizer post-324 portfolio type-portfolio status-publish has-post-thumbnail hentry portfolio-category-france" id="gallery-1928">
<figure>
<a class="csmx-media " href="<?php echo $SITE_URL; ?>media/gallery-photos/<?php echo htmlentities($galleryphoto['galleryphoto_file'], ENT_QUOTES, 'UTF-8'); ?>" title="Sarah">
<img src="<?php echo $SITE_URL; ?>media/gallery-photos/<?php echo htmlentities($galleryphoto['galleryphoto_file'], ENT_QUOTES, 'UTF-8'); ?>" alt="Sarah">
<span class="overlay-background"></span>
<div class="overlay-caption">
<i class="fa fa-picture-o" aria-hidden="true"></i>
<!--<h3>Sarah</h3>-->
<!--<p>Contrary to popular belief, Lorem Ipsum is not simply random...</p>-->
</div>
</a>
</figure>
</div>
<?php } ?>
<?php endforeach; ?>
Aucun commentaire:
Enregistrer un commentaire