Click to See Complete Forum and Search --> : Request: Folder Slideshow


venger
08-24-2003, 01:52 PM
I would very much like to start a discussion that centers around creating a scrip that rotates through images stored in a folder.

"Folder Slideshow"
It starts with the first image stored in the folder... and as people click "NEXT" or "PREVIOUS" it goes to the next file/image until it's finished showing all the images in the folder. (Can start again from 1st image (or just show "no more images" message)).

---

Another idea, based on a Gallery Script I already saw in the Javascript collection:

"Folder Gallery"
The user tells the script what folder the pictures are in and it generates thumbnail web pages with all the pictures... The thumbnails are then clickable, to view the full sized image.

Anyone know if these already are out there?
Yours,
Venger

David Harrison
08-24-2003, 02:03 PM
I have a slideshow script that cycles through images as long as you type in the locations of the images in the source. It could be easily modified to show thumnails and/or change image with next/previous buttons.

I don't know about just using whatever items are in a specific folder though.

xataku_nakusute
08-24-2003, 02:06 PM
i agree with lavalamp....plus, there wouldnt be much change nor would it take that much more time either....
so, whats the purpose of making it only for a certain folder without simply typing in the filename?

David Harrison
08-24-2003, 04:05 PM
I thought I'd post the script you were describing minus the getting images in a folder bit, you have to put their locations into an array yourself.

venger
08-24-2003, 08:11 PM
Originally posted by xataku_nakusute
i agree with lavalamp....plus, there wouldnt be much change nor would it take that much more time either....
so, whats the purpose of making it only for a certain folder without simply typing in the filename?

The point of having it show the entire folder is that it could handle any number of pictures... and any folder, without having to type in the thousands of image names.

Also, it could point to ANY folder(s) and the script would not change. Only the folder location would change. Each folder could have thousands of images in, but the only fixed URLs would be the ones pointing to the 10 folders.
Not individual pictures.

Perhaps I should have stated that to start with.
;-)

I know it can be done... I did it for my Mac many years ago... The trick is to read the folder line by line... but I don't know how one does that in Javascript.

I'll be taking a PHP course soon, though... and that might help. I know it can be done, that's the main thing. I just don't know how to do it with the programming language at hand.

Yours,
Venger.

David Harrison
08-25-2003, 01:28 PM
Well the chances are that it can't be done with javascript alone, so if php could scan a folder for images it could create a javascript array and then client side javascript could do the slideshow, a bit like the one I posted.

venger
08-25-2003, 03:27 PM
Originally posted by lavalamp
Well the chances are that it can't be done with javascript alone, so if php could scan a folder for images it could create a javascript array and then client side javascript could do the slideshow, a bit like the one I posted.

Ok, - What if the images were named "100.jpg" to "999.jpg" (or up to the highest number (ie. 424)) is there some way to make the filename a variable, so it counts up from 100?

There was a program called "MultipleRename" that worked well in Win95... I guess it would still work for XP? That way it would be easy to rename the files numerically.

SUGGESTED CODE

put 100 into Count
NumToChar Count
put Count + ".jpg" into imagev
put <img src=folder1/imagev> onto webpage

if "next" then Count=Count+1
if "prev" then Count=Count-1

if Count < 100 then exit
if Count > 999 then exit


Just some ideas to find a compromise.
You can see how the Folder number could also be a variable and count from 1 to 10, or something like that.

David Harrison
08-25-2003, 03:33 PM
If you supply a directory, imglimit and a file extension this script will do the rest:

var directory="http://www.blahblahblah.co.uk/images/"
var imglimit=999;
var filetype=".gif";

var imgarray=new Array();

for(n=100;n<imglimit;n++){

imgarray[imgarray.length]=directory+n+filetype;

}

venger
08-30-2003, 06:40 PM
Many thanks...

It's not quite what I was looking for initially, but while it solves some of the problems... it creates others.

For the script to work, the names of the images need to be changed. Unfortunately, in practice, since the names of the images were to double as description of the images as well, to be displayed under the picture (the filenames were stuff like "me_and_pope.jpg"), the decription is lost, since now the same file would just be "234.jpg". Saying nothing but where we are in the sequence.
*sigh*

I'm sure there has to be a way for Javascript to read from a folder (line by line) until there are no more files to read?

* Possibly reading all the filenames in the folder, into an array, then using the array to show the pictures on one web page, might work... if there was some way of making Javascript read the filenames in the folder into an array?

Another variant/possibility:
The Javascript generates the HTML for the web page that each picture is shown on, each time, so each picture gets it's own generated web page? (yes, not unlike the "Javascript Album" script) - Then you could go for something like a random background color? Just some more ideas.

I'm sure we'll find a solution, eventually.

David Harrison
08-31-2003, 08:52 AM
The random background colour I can help you with:

var colours=new Array();
colours[0]="#ff0000";
colours[1]="#00ff00";
colours[2]="#0000ff;

// Not to sure about the line below, I haven't tested it but I know that a random colour will be selected.

document.getElementByTagName("body")[0].bgColor=colour[Math.round(Math.random()*(colours.length-1))];

However JavaScript cannot scan folders for images, it can only display images when you give it pathnames.

shirtbloke
08-31-2003, 10:51 AM
I too wrote something like this years ago using Amos Basic on an Amiga. If memory serves, I used two instructions - Dir First$ and Dir Next$ to read the contents. Does javascript have a way of doing this?

If you can get the code to work, you should be able to point it at any web directory, and get a read of all the files in there. Which sounds rather unsafe. Which might be why it's difficult to do.

Khalid Ali
08-31-2003, 10:53 AM
?????????????

shirtbloke
08-31-2003, 10:55 AM
Damn - I just pressed the wrong button.
This should have gone in the replies to Request: Folder Slideshow .
Sorry about that.

shirtbloke
08-31-2003, 10:56 AM
I too wrote something like this years ago using Amos Basic on an Amiga. If memory serves, I used two instructions - Dir First$ and Dir Next$ to read the contents. Does javascript have a way of doing this?

If you can get the code to work, you should be able to point it at any web directory, and get a read of all the files in there. Which sounds rather unsafe. Which might be why it's difficult to do.