Single and multiple images
Hi, I am building a site that needs to be as simple as possible for my client, I have an image upload area so they can load up a single image or multiple images, so basically I want the CSS to recognise if a single image has been loaded up or if multiple images have been loaded up, so if only one image has been uploaded I want the CSS to be max-width:100% but if more than one image then the CSS changes so the image is max-width: 50% and float:left. Can this be done?
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.
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php