Jump to content
xisto Community
Sign in to follow this  
galexcd

Random Images how to make a random image?

Recommended Posts

Here's an even smaller random image script but it requires php instead. Xisto has php so all your visitors will be able to use this.

 

For this script each image needs to be called something1.png, something2.png, something3.png etc. You can change the text "something" and the image extension into something you choose but the number must remain in place.

 

It is assumed that all your images are stored in the directory images/ but you can change that in the script. All your images must be stored in the same directory and all image extensions must be the same.

 

<? // Selects a random number from 1 to 4. Change 4 to the amount of images you have   $randomNumber = rand(1,4);  // Displays the image  echo "<img src=\"images/something" . $randomNumber . ".png\" alt=\"My random image\">";?>

And that's it :)

Share this post


Link to post
Share on other sites

No, sorry should have clarified myself... i dont mean on the html page, i mean on the image itself... like a dynamic image...HOw do i add lines of coad to the acctual image itself... :) thanks!

Share this post


Link to post
Share on other sites

Adding codes on the image itself is impossible. Unless your a hacker and is attacking a security hole on images(It does exists). PHP can create dynamic pictures and Xisto has GD enable,hasn't it? Describe what you want and we can tell you other method of doing what you want!

Share this post


Link to post
Share on other sites

Ok, like how do they make those couters?Its one image like counter.jpg, but every time you refresh the image it automatically counts... is that php generating an image? and if so, why isn't it a php page i link to, instead of a jpg?Example here-------Another thing how do they make those random message board sig things, like i have one in my sig... its different every time, but its just a regular <img> tag... is that PHP generating the image? and if so, why isn't it a php page i link to, instead of a jpg?--Thanks! ^_^

Share this post


Link to post
Share on other sites

Maybe it's a virtual directory and the jpg extension is generated by PHP. But the virtual directory ends with a .php doesn't it?They maybe make php recognises the jpg extension and php will process every jpg file there!

Share this post


Link to post
Share on other sites

I think Danasoft did it with php virtual directory and apache's mod-rewrite (I've just done the research on this and I'm not guranteeing it's right).The folder sig is a "real" directory but nothing exists in there except 2 files, "index.php" and ".htaccess". The content htaccess tells apache to forward all the files with a ".jpg" extension to the php file which process the files.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.