I have used the carousel from Malsup to add a carousel to my webpage. What I would like to do in addition is automatically add the file name of each image to the images fed dynamically to the carousel. I change the images regularly, where the quantity of them can also change. I would be very grateful if someone could suggest a way to add the filename of each image to either the bottom of the image (perhaps superimposed on it) or in the space below the image where an "Alt" name would appear.
Thanks in advance for any help you guys can give.
Cheers, David
The markup is as follows:
<div id="slideshow" class="pics">
<img src="sliderimages/ride_4481.jpg" width="400" height="300" />
<img src="sliderimages/ride_4482.jpg" width="400" height="300" />
With CSS styling as follows:
.pics {
height: 332px;
width: 432px;
padding: 0;
margin: 10px auto;
display: block;
border: 1px solid #ccc;
border-radius: 8px;
}
.pics img {
padding: 15px;
border: 1px solid #ccc;
background-color: #eee;
width: 400px;
height: 300px;
top: 0;
left: 0;
border-radius: 8px;
}
The script to run the slideshow is (with a lot of comments to serve as reminders:
<script type="text/javascript" src="js/jquery.cycle.all.js"></script>
<script type="text/javascript" src="js/jquery.easing.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// start slideshow
$('#slideshow').cycle({
fx: 'cover',
easing: 'easeOutBounce',
pause: 1,
speed: 1000,
timeout: 1500,
before: onBefore
});
var slidesAdded = false;
function onBefore(curr, next, opts) {
// Make sure not to call addSlide before it is defined
if (!opts.addSlide || slidesAdded)
return;
// Add slides for images 3 - 8 or whatever number of slides you want to add. Just amend the var i=3; < x; i++ functions below where x is any number.
// Also ensure you have this number of pictures available or you will get grey placeholders instead!
// Slides can be a DOM element, a jQuery object, or a string
for (var i=3; i < 3; i++)
opts.addSlide('<img src="sliderimages/ride_448'+i+'.jpg" width="400" height="300" />');
slidesAdded = true;
};
});
</script>