Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Random Image/ Slideshow

edited November 2005 in Vanilla 1.0 Help
Hey, I was wondering if anyone could lend a hand. I am after a php (or javascript. not sure what will work best) script to randomly display an image from a directory. I would also like the image to change every x seconds. So that would be a BIG PLUS! Re-sizing would, again be a plus, but really not so big an issue, so this comes later on. If anyone HAS or KNOWS OF a script that does this, if you could share this information with me it would be great. Any help is much appreciated.
«1

Comments

  • Here is some javascript I found I think could be used. What I need now is a way to have it select from a directory, and not from specific, pre specified files. ---------------------------------------------- var images = new Array(); images[0] = "image1.gif"; images[1] = "image2.gif"; images[2] = "image3.gif"; function ShowImg() { var number = images.length; var increment = Math.floor(Math.random() * number); var strTemp ='<img src="' + images[increment] + '">'; document.write(strTemp); } var rotate = 5000; var count = 0; function RotateImg(myImage){ myImage.src=images[count]; count++; if(count==images.length){count = 0;} setTimeout("RotateImg(myImage)",rotate); } ----------------------------------------------
  • Um. I *think* I could write this in php. The idea doesnt seem too hard. Remind me when i get home.
  • How do I know when you get home? *reminds anyway*
  • that will have been about right. unfortunately for the first evening in months i didnt check vanilla till i'm off again. Keep bumping.
  • edited August 2005
    *bumps *
  • are you home yet?
  • hi. i was just thinking about this. then i stopped. I'll get onto it now.
  • cheers. I really appreciate it.
  • to do it with php, you'd have to reload the document - not sure if this is the effect you'd be after.
  • no. not realy, I would rather them just sort of 'roll on by' in a slide show. So, the image changes every 5 seconds for example.
  • yeah - js or flash. flash would be more graceful.
  • I dislike flash.
  • edited August 2005
    meh. here's roughly what i think youre talking about in php anyway since i've done it. http://badassg.me.uk/randomimage.php The source is there under .phps if anyone wants to take it and have a play around or even use bits of it along with javascript. (n.b. it refreshes 1 of 2 images because there are only 2 in the directory not cuz its broke.) If you want any of the source explaining (its really pretty simple if you've used php before) i'll be around for the next 10 otherwise i'm sure someone else can give you a hand.
  • wow. thanks mini. No explanation needed. (I know you are not here anyway). Now... Is anyone up for some JS integration? I would like ot have this WHITHIN another page, so I think this on its own won't/ can't refresh an image ONLY (not the whole page). Any takers?
  • as a thought you could stick that in a frame (i didnt put resizing on but i/someone could if it'd help) and just have it refresh that frame. JS would probably be much better but i'm afraid i've never used it.
  • That would be great as a temporary measure. I am working on JS version, but I must say, I am not very good at it. Thanks for your help mini.
  • no probs. If you know how to do the transition with JS you could always use my php to do the image selection...if that helps atall?
  • it does. thanks
  • chuck a post up when you're done. I'll be interested to see how you've got it working. I made a slideshow type thing for my friend a while ago just to flick her through all the pics in a directory (i do think it'd be a nice ability for the filebrowser but i suppose its not really a core feature. I still think it should be extensionised) but that was in order and in a similar fashion to the one above. Transitions or whatever to make it smoother would be nice.
This discussion has been closed.