automatic slideshow of images in folder

Asked by Jaap Bos

Is there a standard script that can check what images are in a specific folder and than make a slideshow out of it?
I have tried to get this working but I can't get it to work:

First created a getimages.php file with the code below

<?
//PHP SCRIPT: getimages.php
Header("content-type: application/x-javascript");

//This function gets the file names of all images in the current directory
//and ouputs them as a JavaScript array
function returnimages($dirname=".") {
$pattern="(\.jpg$)|(\.png$)|(\.jpeg$)|(\.gif$)"; //valid image extensions
$files = array();
$curimage=0;
if($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))){
if(eregi($pattern, $file)){ //if this file is a valid image
//Output it as a JavaScript array element
echo 'galleryarray['.$curimage.']="'.$file .'";';
$curimage++;
}
}

closedir($handle);
}
return($files);
}

echo 'var galleryarray=new Array();'; //Define array in JavaScript
returnimages() //Output the array elements containing the image file names
?>
--------------------------------
Then created a page called test.html like below

<html><head>
<script src="test/getimages.php"></script>
<script type="text/javascript">

var curimg=0
function rotateimages(){
document.getElementById("slideshow").setAttribute("src", "test/"+galleryarray[curimg])
curimg=(curimg<galleryarray.length-1)? curimg+1 : 0
}

window.onload=function(){
setInterval("rotateimages()", 2500)
}
</script>
</head>
<body>
<div style="width: 490px; height: 390px; text-align:center">
 <img id="slideshow" src="test/p_0001.jpg" name="slideshow" width="490" height="390" align="middle" /></div>
</body></html>
------------

Question information

Language:
English Edit question
Status:
Solved
For:
Xibo Edit question
Assignee:
No assignee Edit question
Solved by:
Jaap Bos
Solved:
Last query:
Last reply:
Revision history for this message
Jaap Bos (mp3speler) said :
#1

I put the code from test.html in the embedded html field

Revision history for this message
kobus44 (kobus44) said :
#2

I use JW Image Rotator in my setup, available at http://www.longtailvideo.com/players/jw-image-rotator/

JW Image Rotator uses playlists to locate your pictures, after which it displays these in a flash based slideshow (various orders, various transitory effects). I currently have it set-up stupid simple: I have a couple of picture folders located in the root of my webserver which I can access via ftp. The server reboots every night and automatically creates xml playlists of these picture folders. I have equiped each picture folder with a basic html file which loads JW Image Rotator together with the preferred xml playlist. In Xibo, I make a layout with web content, which I point to the html file on my server and presto, my screens show a nice flash based slideshow.

It's a bit of a work-around, and I would definitely prefer an all-in-one simple but effective php solution, which allows me to upload pictures and arrange folder structure in a web-based environment; automatically build xml playlists and preferrably, a built-in slideshow based on flash. I have found some third party solutions, but none satisfies my needs 100%. As I am not a php coder, any suggestions are welcome.

Revision history for this message
Mariana Lopes (marianamlopes) said :
#3

Hi!
I think I've done everything Jaap Bos said:
* I created the "test" folder on the same level as 3rdparty, config ...
* put some images inside of test folder
* put getimages.php inside of test folder
* put the code from test.html in the embedded html field.
But I get a red cross in the place of the images :-( Can you help me?
Thanks in advance!