Random Images - how to make a random image?

Pages: 1, 2
free web hosting
Free Web Hosting, No Ads > CONTRIBUTE > Computers

Random Images - how to make a random image?

galexcd
Hi! I want a random image, do i need to set that up with your web host? Can i implement coad into my images?

Thanks! smile.gif

Reply

MarCrush
If you want to use javascript for random images, here is the code:
Source: http://javascript.internet.com/miscellaneo...ndom-image.html
CODE
<!-- TWO STEPS TO INSTALL RANDOM IMAGE:

 1.  Copy the coding into the HEAD of your HTML document
 2.  Add the last code into the BODY of your HTML document  -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->

<HEAD>

<script LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
// Set up the image files to be used.
var theImages = new Array() // do not change this
// To add more image files, continue with the
// pattern below, adding to the array.

theImages[0] = '1.gif'
theImages[1] = '2.gif'
theImages[2] = '3.gif'
theImages[3] = '4.gif'

// do not edit anything below this line

var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
  preBuffer[i] = new Image()
  preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'">');
}

//  End -->
</script>

</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document  -->

<BODY>

<script LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
showImage();
//  End -->
</script>

<p><center>
<font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size:  1.49 KB -->


Well sorry if I was suppose to use quote tags instead of code.

It requires javascript, and you don't need to set it up with your web host. Every time you refresh the page, it will show a different image.

 

 

 


Reply

electriic ink
Here's an even smaller random image script but it requires php instead. Trap17 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.

CODE
<?


// 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 smile.gif

Reply

galexcd
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... unsure.gif

thanks!

Reply

pawitp
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 trap17 has GD enable,hasn't it? Describe what you want and we can tell you other method of doing what you want!

Reply

galexcd
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!


smile.gif

Reply

pawitp
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!

Reply

galexcd
hmm not sure, but just look at the image in my sig... how does danasoft do it?
its random, but it has a .jpg extention!

Reply

pawitp
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.

Reply

galexcd
ok... i see... i guess...

Thanks for all your help!

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Pages: 1, 2

Searching Video's for random, images, make, random, image
advertisement



Random Images - how to make a random image?



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE