/ Published in: PHP
have more than 1 avatar
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* rotating avatars create a directory on your webserver, call it avatars and put a few avatars in it, along with this file. (index.php) ( make sure the avatars are about the same size, and preferably square ( width == height ) ) check http://www.yourdomain.com/avatars/ to see the result. Refresh the page to see another avatar. */ function listImages ( )//reads images in current directory, returns array with filenames { { } return $linklist; } function mkImg ( $file, $ftype )//returns an image with filetype $ftype, sourceimage is $file { switch ( $ftype ) { case ".jpg": break; case ".gif": break; case ".png": default: break; } } //read the images in the current directory $images = listImages ( ); //pick a random one //for use on forums -> link to /path/to/index.php?ftype=.jpg (fools SOME forum software into thinking it's a jpg) $ftype = $_REQUEST['ftype'] ? $_REQUEST['ftype'] : ".png"; //return the randomly picked image mkImg ( $rnd, $ftype );
URL: http://www.poehey.nl/media/img/avatars/