Random Image?

Hi! I’ve ran a search on the forum and tried everything I could find here and on google, and I can’t get any random image script to work for me.

I’ve read through http://alistapart.com/articles/randomizer/ and tried it, but the image didn’t show up at all. (When I went to the script page, however, it worked. The image just won’t show up on my website.)

I also read through http://wiki.dreamhost.com/index.php/Allow_url_fopen this, and tried to make sense of it, but as I’m really new to most things, I don’t understand it at all. I tried my best to work what it said into different scripts, but I guess I don’t understand it well enough.

Is there something else I can do to make random images appear on my website? I found one script that worked, but I could only have one image showing up, and I need about five-ten.

There are quite a few random image display scripts out there, but most of them are set up to only display a single image at a time.

Have you considered using an image rotator script, that will reload the “random image” at interval rather than trying to display numerous “random” images at once (seem to me that might be a little easier on the server).

If you would share a link to your attempt at using the alistapart.com method, some here might could help you debug it. :wink:

A note on the allow_url_fopen issue: As long as you are calling images from your own server (not from another site’s web pages) you won’t need to go to the bother of “cURLifying” the script as described in the wiki. You can just change the code that indicates the image file from “http://somethingorother.domain.tld/images/picture.jpg”, or what ever, to just use the path to the file on your server (like “images/picture.jpg” or “/home/yourusername/yourdomain.tld/images/picture.jpg”).

You can also avoid that whole issue by using a perl or python script instead of PHP. many perl scripts exist for this (many work in conjunction with SSI).

Was there a particular script that you liked but were not able to get installed?

Oh yeah, and don’t forget about javascript random image scripts.

Here is one you might want to check out, It is a “generator” (you give it the urls for the image(s), and it generates the javascript for inclusion in your page): http://www.drummy.org/javascript-random-image/


Ahh, I see! I altered the script I was using to fit what you said about the allow_url_fopen problem, and it seems to be working better, except now I get an error along with the images, and I’m not sure what’s causing the error.


I get an error on the script page as well.


Take a good hard look at your code, particularly around line 58 of image.php, and then look at this:


Also, depending upon the code in your script, you might find this previous thread helpful (note I borked the “example” url in that post, and missed the chance to fix it - if you want to see the “funkycat”, go here.