Jump to content

Hot To Make A Random Avatar


borfast

Recommended Posts

I forgot about the IE page! :)

I never see it, since I never use IE :)

I have to update it, some of the stuff I have there is not 100% correct... :\

 

And now that I've read your How-to, I have a question. Let's say I want to use a mapped area of a single page on a website, instead of implementing this as an avatar on a forum...

I'm not sure about what you mean by "a mapped area of a single page"... :lol: but if you want to use a random image on a page, you just have to write the usual <img> tag and point the src attribute to the avatar.jpg file, just as you'd do when configuring an avatar. Is this what you wanted?

 

By the way, Lianna, did you find it hard to understand where to click to keep browsing the website? I'm asking this because of the "warning" on your first post. It sounded like you got a bit lost, there, and were trying to prevent others from losing themselves, too. If so, I'd like to know, because although I want people to see that page, I don't want them to think that's all there is to see on my web site ;)

Edited by TCH-Raul
Link to comment
Share on other sites

Raul,

 

re: the hijack page...no, it just took me several seconds to realize what the page actually was and that it was a part of your site. :) Just didn't want folks to get freaked out when they got there and then just hurry close the page because they thought they really had been hijacked and bad things would come if they didn't leave right away. Does that make sense?

 

re: image map, yes, that's exactly what I was talking about.... Say I have a large image on my home page and I want a portion of that image to display the random image generated....k, hang on, I'm making this much more difficult than necessary aren't I? Resolution: the large image should be the one with multiple versions and then randomized. (Sorry for my babbling everyone.)

 

Anyway, you answered my question perfectly. Thanks!

Link to comment
Share on other sites

OK, I updated the page with a tip about using the random images on a web page :lol:

 

Lianna, about the hijack page, I guess you're right, I have to change it a bit so people don't run away from my web site :) Thanks for the heads up :)

 

About the image, if you have a large image that needs only a part of it generated randomly, what I'd do is slice the image in pieces, join them in a table (or, if you're feeling brave, using CSS ;)) and randomize only the... well, random part of it ;)

 

There's no need to make your site visitors download a new big file everytime. This way, the static parts of the image are cached by the browser, so they don't need to be downloaded again wasting your visitors' time and both yours and theirs bandwidth.

 

Did I make sense?

Link to comment
Share on other sites

Yeah, being "hijacked" was at first scary...but I know better and don't scare easy :)

 

you just redirected the user to a different page based on their browser.

 

Maybe some rewording so you don't really scare the viewers away from your site...the idea is to keep people there, not send them running for the kill button.

Link to comment
Share on other sites

K, now I feel really dumb. :)

 

The hijack page scared the crap outta me and after quickly perusing the first part of the page, I slammed my browser window shut! Tight! :lol:

I came back here to continue reading this forum's messages and found out how silly I was. Went back to the page, saw the "continue..." link and continued on... feeling somewhat foolish....

Just thought I'd pop in and admit to my fears in case you were wondering if people were actually scared away and running for the kill switch. :)

Link to comment
Share on other sites

Thanks for the feedback about the hijack page :)

I'll take care of it, just have to think about a better introductory text.

 

What about the how-to/mini-tutorial? Has anyone tried it yet? When are we going to see a flood of random avatars here on the forums? :P

Link to comment
Share on other sites

Very neat Raul. I will have to find some images when I find some time :)

 

 

(....approximately 3 minutes later.....................) It occurs to me that your code may well indeed come in handy to rotate sheet music and exercises on my lesson site. I will give credit of course, if it's ok to use?

Edited by boxturt
Link to comment
Share on other sites

Bruce, I started my change a long time ago when I first tried Opera. I fell in love with it's tabbed browsing and a couple of weeks later, ditched both IE and Outlook Express. It was my first step to say "bye bye, virus and worms!" and to freedom :)

 

Some time passed by and Mozilla started to become a usable browser. When Mozilla incorporated tabbed browsing, I made the switch and used it for both e-mail and web browsing until I completely stopped using Windows. After that I still used Mozilla for browsing the web but I started using Ximian Evolution for e-mail.

Finally, when Firebird reached 0.6, I started using it exclusively for web browsing.

 

If you dedicate some time (not much) to see the good stuff in Mozilla, I'm almost sure that you too will drop IE :P

Link to comment
Share on other sites

Tyler, it's more than OK for you to use it!

I'll be happy if that code helps you with your tasks :)

And you don't need to give me credit if you don't want to. Would be nice but it may require you to add ugly stuff to the page, so forget it and just use the code for whatever you want :P

Edited by TCH-Raul
Link to comment
Share on other sites

Raul, I used Opera when it first came out. Then they went the way of ad support for the free version. I was also a proponent of Netscape before the browser war. Then IE just blew everyone away with IE4 and I gave up on Netscape. But I have to admit NS 7.1 isn't bad but I really like Firebird.

Link to comment
Share on other sites

  • 2 weeks later...

cloudrm, can you describe the problem? What exacltly doesn't work? I'd like to make those steps as simple and easy as possible and if you didn't manage to do it, then I guess I could still improve the text :(

 

Ty, did you use it for the random song box, on your guitar lesson pages? Pretty cool! :(

Been there yesterday and noticed it. Couldn't help thinking if you had used it ;) ;)

Link to comment
Share on other sites

cloudrm, can you describe the problem? What exacltly doesn't work? I'd like to make those steps as simple and easy as possible and if you didn't manage to do it, then I guess I could still improve the text ;)

I'm not sure why it didn't work, I followed the instructions. I'll go back and try it again.

 

created the text file . . .named it "avatar.jpg"

created the text file . . .named it ".htaccess"

created folder . . ."avatars"

put all the photos in the folder with the new files.

uploaded. . . changed the link . .:( just the dreaded box with the "red x" :)

 

sounds cool if I can get it to work!

Link to comment
Share on other sites

cloudrm, when I try getting http://www.cloudroomstudio.com/avatars/avatar.jpg, I get the following error message:

Warning: Cannot modify header information - headers already sent by (output started at /home/cloudro/public_html/avatars/avatar.jpg:2) in /home/cloudro/public_html/avatars/avatar.jpg on line 10

So that means there's something wrong with the PHP code in avatar.jpg. Could you please copy/paste it here so I can try to figure out what's wrong? :)

 

By the way, nice avatars ;)

Are you into some sort of circles fanatism thing? :P

Just kidding, the avatars are cool. I bet it'll look nice to see them all different but maintaining the circle pattern :(

Edited by TCH-Raul
Link to comment
Share on other sites

<?php

$dh = opendir(".");

while(false !== ($file = readdir($dh)))

if($file != ".htaccess" && $file != "avatar.jpg" && $file != "." && $file != "..")

$filelist[] = $file;

 

srand((double)microtime()*1000000);

$picnum = rand(0, sizeof($filelist) - 1);

header("Location: " . $filelist[$picnum]);

closedir($dh);

?>

 

 

that's the code I copied & pasted. I'm wondering if it has something to do with the jpg extension?

 

the avatars are part of a series of abstract photo's that I sell/show etc.

Link to comment
Share on other sites

You did quite some cleaning job, there. But I don't see anything that could be causing the error.

 

The error message says that the script output started on line 2, which means that it started on the line with the opendir() function. This means there's something going wrong while opening the directory.

 

Try adding this at the beginning of the script, right after the opening <?

error_reporting(E_ERROR | E_WARNING | E_PARSE);

That should make opendir() spit out the error that's making it fail and let me know what it says.

I'd bet it has something to do with permissions but it's really strange :)

Link to comment
Share on other sites

Glad to see it works :)

Just a tip: remove the htaccess.txt file from that directory, or else, sometimes the selected file will be that one and you'll get no image displayed - just like right now :dance:

Edited by TCH-Raul
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...