Single and multiple images

2 posts by 2 authors in: Forums > CMS Builder
Last Post: September 30, 2019   (RSS)

By gkornbluth - September 30, 2019


I think you could count the number of images something like this (assuming this is a detail page):

<?php $imgcount=0 ?>

<?php foreach ($yourtableRecord['your_img_field'] as $index => $upload): ?>

<?php $imgcount++ ?>

<?php endforeach ?>

Then where you want to change the CSS:

<?php if($imgcount==1): ?> max-width:100% <?php elseif($imgcount>1): ?>max-width: 50% float:left <?endif ?>

I'd include some code to handle a no image uploaded condition

Take a look at this post, it may give you some ideas.


Jerry Kornbluth

The first CMS Builder reference book is now available on-line!

Take advantage of a free 3 month trial subscription, only for CMSB users, at: