Using 'Sliding Image Gallery' to create slideshow with unlimited images

  You are currently not logged in. You can view the forums, but cannot post messages. Log In | Register

12-Jan-12 10:36
Thank you Matt for creating Sliding Image Gallery!

Just finished learning basics of html/php/css.Now I am building my first web app. I have created a php file that sends back a random image from a database of thousands of images. Let's call this php file some_file.php

Current sliding image gallery code uses fixed set of local images for slideshow. Now i want to modify sliding image gallery code such that it pulls images from some_file.php and create a never ending slideshow. Any hints/suggestions/sample code on how to proceed.

Thank you in advance!
14-Jan-12 15:18
Any inputs that can get me started will be very helpful
16-Jan-12 02:45
@aspire: More info needed. When you say some_file.php "sends back a random image", do you mean it returns a URL for a random image hosted on the server, or that it returns the actual binary image data for a random image that you're storing in a database table as a blob?

--
Matt Doyle, Elated
3rd Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/
16-Jan-12 09:10
as of now, it returns binary image data

Will it be easier if it returns a URL?
19-Jan-12 23:37
@aspire: A URL is more conventional but binary image data is fine too. In fact it's easier.

A simple approach would be to just put this in your image gallery markup:


<div id="gallery">
<img src="some_file.php" alt="" />
<img src="some_file.php" alt="" />
<img src="some_file.php" alt="" />
<img src="some_file.php" alt="" />
...
</div>


Add as many img elements as you want to have in the gallery. You don't get image captions of course, but it would work.

If you want to have a never-ending (and continuously scrolling?) slideshow then you'll need to hack the JavaScript to call moveRight() periodically using setTimeout(). You'll also want to hack moveRight() to pull a new image from some_file.php and add it to the end of the list, and probably remove the first image (and disable moveLeft()) to stop the DOM getting too big. Fiddly, but doable.

--
Matt Doyle, Elated
3rd Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/

 
New posts
Old posts

Follow Elated