REGISTER or LOGIN to have the annoying ads removed.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PHP Avatar Rotator
PHP Avatar Rotator

Ive you havent noticed, my avatar rotates on each page.
Heres a bunch of code that you can use to get the same effect.

Before I start theres a few things I need to point out.
Ok so heres how to do it.

- - - - - - - - - - - - - - - - - - -

- First things first you need to create a new textdocument.

- Once opened paste the following code into it.

PHP Code:
*       VERSION 2

$path "/avatars/";    // Path to your avatar folder relative to the root directory of your site


$dir $_SERVER['DOCUMENT_ROOT'].$path;
$avatars = array();

// Open avatar directory and read its contents into an array
if (is_dir($dir)) {
    if (
$dh opendir($dir)) {
        while ((
$file readdir($dh)) !== false) {
            if (
filetype($dir.$file) == "file" && getimagesize($dir.$file)) {

// Create random avatar
$img $dir.$avatars[rand(0count($avatars)-1)];
$info getimagesize($img);

if (
$info[2] == 2)
header('Content-Type: image/jpeg');

elseif (
$info[2] == 3)
header('Content-Type: image/png');

header('Content-Type: image/gif');

Nothing needs changing in it and it should be ready to go.

- Just save it as avatar.php, making sure after you have saved it that it is an actual PHP file and not avatar.php.txt Smile

- After you have create the php file, create a new folder called avatars

- In this folder you will have all the avatars you want to rotate.
You really want to have all image dimensions exactly 100px x 100px. Alot of sites dont allow any bigger than that and some resize them but some do not. And if they do and your image isnt 1:1 then the image will be squashed to 100px x 100px. So its in your interests to resize it Smile

- After that upload everything we have just created to the ROOT of your webserver.

- After everything is uploaded then you want to check it by typing in this link. Obviously changinging "" to your web url.

- Hit refresh a few times and the avatar should change each time.

- Now all you have to do is go to your UserCP, along the left handside click change avatar. Then where it give you the option to upload the avatar by url, paste that url in Smile

- Hit save and thats it.

Good luck Smile
This one seems new to me. I might give this a try soon. Thanks.
Link is broken.
(Sep 26, 2011, 11:53 PM)F4T4L 3RR0R Wrote: Link is broken.
Was just a bracket getting in on the action.
You dont need to visit the site anyway, all the info is posted in the thread Smile
thank's you,
I try out this tutor.
many tahnk's Smile

Possibly Related Threads...
Thread Author Replies Views Last Post
  Need Mod/Plug-in allow user to add avatar when registration donggiagia 1 1,759 Sep 26, 2013, 02:10 PM
Last Post: MyBB Freak

Forum Jump:

Users browsing this thread: 1 Guest(s)