Page 1 of 1 [ 16 posts ] 

hermit
Velociraptor
Velociraptor

User avatar

Joined: 19 Dec 2005
Gender: Male
Posts: 495
Location: Upstate NY

27 Dec 2005, 3:07 am

I have written a php script that randomly chooses an avatar each time a thread is loaded. If there is a call for it, I could post it for others...



Larval
Veteran
Veteran

User avatar

Joined: 15 Nov 2005
Gender: Female
Posts: 1,037

27 Dec 2005, 10:48 am

Um I see the same one each time.

But yes I'd like to see it. ;)



alex
Developer
Developer

User avatar

Joined: 13 Jun 2004
Age: 38
Gender: Male
Posts: 10,216
Location: Beverly Hills, CA

27 Dec 2005, 11:10 am

Larval wrote:
Um I see the same one each time.

But yes I'd like to see it. ;)


I see different ones. Maybe you're caching the image.


_________________
I'm Alex Plank, the founder of Wrong Planet. Follow me (Alex Plank) on Blue Sky: https://bsky.app/profile/alexplank.bsky.social


Larval
Veteran
Veteran

User avatar

Joined: 15 Nov 2005
Gender: Female
Posts: 1,037

27 Dec 2005, 11:26 am

alex wrote:
Larval wrote:
Um I see the same one each time.

But yes I'd like to see it. ;)


I see different ones. Maybe you're caching the image.


Yes, your right. It's working now.



hermit
Velociraptor
Velociraptor

User avatar

Joined: 19 Dec 2005
Gender: Male
Posts: 495
Location: Upstate NY

27 Dec 2005, 12:51 pm

Hahaha am I really that easy?

Even one person asking is enough... enjoy everyone.

Alex I hope it's ok with you. It checks for image size and type before returning the image. If the script fails no avatar image is generated. I couldn't see any reason why you are anyone else would mind so I just did it in the wee hours last night. If it ever is a problem let me know.

The following script requires you to have your own server space capable of running php. The script is called by WrongPlanet as your offsite Avatar image, executed offsite, and returns a raw image file. I think the general directions are pretty clear- just make a new folder/directory on your site, drop in all your avatar images and this file, set your avatar URL in the profile page, and you're off. It automatically scans available images in the directory and picks one at random. With tweaking I could give it any number of additional features (change once a day, scroll through directory, etc). Or any of you of course are welcome to add to it or improve it, I'm just learning php recently in hopes of getting a hermit-like job....


Save the following as "avatgen.php"....

Quote:
<?
//Simple random image generator for use in an avatar or signature.
//Create a directory 'yournewdir' for the images, and drop this script in with the images.
//It will return a raw image when called. Use $maxsize to control image size.
//$where is the new directory path- '/yourpath/yournewdir/'
//Do not enter the whole URL in $where (NOT this part: 'http://yoursite.net') just the file path.

//To use in place of an image, avatar, or sig,
//substitute the URL of this file as the image link: ex "http://yoursite.net/yourpath/yournewdir/avatgen.php"
//For WrongPlanet enter the URL of this file as your avatar.

//If prescreened for image type (uncommon, not necessary for WrongPlanet) rename the file "avatgen.jpg"
// AND create a .htaccess file (Apache) in yournewdir: "AddType application/x-httpd-php .jpg"

//Free to use, modify, and share. Contact [email protected]. Please retain these directions for others.

$where = '/yoursites/yournewdir';
$i = 0;
$maxsize=6144; //6kb limit
$photos=array();
$temp = opendir($where);
while (false !== ($file = readdir($temp))) {
if (($file != '.') and ($file !='..')){
$tag=strrchr($file,'.');
if (eregi("jpg|gif",$tag)) //check if image
if (filesize($file)<=$maxsize)
$photos[++$i]=$file;
}
}
closedir($temp);

if ($i != 0){ //if any matches
$which=rand(1, $i);
$av = $where.$photos[$which];
readfile($av);
}
else die('');
?>


eek! edited for typos.



Last edited by hermit on 30 Dec 2005, 1:00 am, edited 1 time in total.

hermit
Velociraptor
Velociraptor

User avatar

Joined: 19 Dec 2005
Gender: Male
Posts: 495
Location: Upstate NY

28 Dec 2005, 3:32 am

I know we probably don't need a site full of shifting avatars, but it just struck me another use would be a once-in-a-while avatar that pops up.

Just use this like the instructions say, and make say, 9 copies of your normal one. Make one your suprise avatar.

This way, when it does it's thing, 90% of the time you get the same one.

While 10% of the time it's the surprise.

or make 99 copies of the same one!

I spent this evening writing a signature one only to find HTML disabled. However I notice at least one member with an image for a signature... is this grandfathered somehow?



vetivert
Veteran
Veteran

User avatar

Joined: 17 Sep 2004
Gender: Female
Posts: 5,768

28 Dec 2005, 4:18 am

ah. images in signatures aren't really kosher, i'm afraid. but the above is a great idea, especially as the size and format etc. keeps to the guidelines - i do wish everyone would. :(



hermit
Velociraptor
Velociraptor

User avatar

Joined: 19 Dec 2005
Gender: Male
Posts: 495
Location: Upstate NY

28 Dec 2005, 4:58 am

vetivert wrote:
ah. images in signatures aren't really kosher, i'm afraid.


That's ok, it was just going to be an image of text, (look the same as the normal ones, just change) but it'll be useful elsewhere off WP. No worries.

thanks for replying, I was beginning to wonder if it were me! Sometimes I'll miss the simplest things.

Oh- Happy Birthday!



BeeBee
Veteran
Veteran

User avatar

Joined: 31 Mar 2005
Gender: Female
Posts: 2,257
Location: Upper Midwest, USA

28 Dec 2005, 8:11 am

I love the idea of a "surprise" picture every 10th time or so!



en_una_isla
Veteran
Veteran

User avatar

Joined: 31 Oct 2005
Gender: Female
Posts: 2,876

28 Dec 2005, 10:55 am

That is SO neat! Too bad I don't have my own server :(.


_________________
!x75


Larval
Veteran
Veteran

User avatar

Joined: 15 Nov 2005
Gender: Female
Posts: 1,037

28 Dec 2005, 8:22 pm

hermit wrote:
I know we probably don't need a site full of shifting avatars, but it just struck me another use would be a once-in-a-while avatar that pops up.


The script could just be rehashed to pick one picture 9 of out 10 times and the other onyl 1 out of 10 times. No need to litter the directory with multiple copies or links of avatars.

hermit wrote:
I spent this evening writing a signature one only to find HTML disabled. However I notice at least one member with an image for a signature... is this grandfathered somehow?


The exact line he has is this:

[img:6bed9b1863]http://www.danasoft.com/sig/Pikachu\\\ssign.jpg[/img:6bed9b1863]

It didn't work for me though.



MsTriste
Veteran
Veteran

User avatar

Joined: 7 Dec 2005
Age: 61
Gender: Female
Posts: 3,307
Location: Not here

28 Dec 2005, 11:07 pm

Just to let you know, Hermit, I've thoroughly enjoyed seeing all the beautiful photos you post. And now I'm even more amazed at the technology involved. Heck, I can't tell you how long it took me to find an avatar that was small enough to fit the guidelines and is just barely big enough to tell what it is. Sigh.



hermit
Velociraptor
Velociraptor

User avatar

Joined: 19 Dec 2005
Gender: Male
Posts: 495
Location: Upstate NY

28 Dec 2005, 11:47 pm

Larval wrote:
The script could just be rehashed to pick one picture 9 of out 10 times and the other onyl 1 out of 10 times. No need to litter the directory with multiple copies or links of avatars.



Er... yes... I was going for the simple approach that people who don't know php could do. feel free to post the changes or maybe I'll get to it eventually. On the same lines I was trying to save bandwith by having it load all onsite- but as I was writing it the photo galleries that were here a week ago are gone?? Could just load from there and keep it all onsite- but am I an idiot?

Yes- while writing this I noticed the 'gallery' link on the left, I'll investigate...

Larval wrote:
[img:6bed9b1863]http://www.danasoft.com/sig/Pikachu\\\ssign.jpg[/img:6bed9b1863]

It didn't work for me though.


I tried embedding objects too, not in that format but since Vevivert said not Kosher I stopped trying.

Larval you do programming? Maybe I'll post some in the comp. section.

Aylissa: Thank you!. :oops: I suppose I'll have to keep it interesting now. I must say I noticed your flower right away, you chose well.



MsTriste
Veteran
Veteran

User avatar

Joined: 7 Dec 2005
Age: 61
Gender: Female
Posts: 3,307
Location: Not here

28 Dec 2005, 11:52 pm

hermit wrote:
Aylissa: I suppose I'll have to keep it interesting now. I must say I noticed your flower right away, you chose well.


OMG I didn't mean to pressure you, I just wanted to let you know that someone out there noticed and appreciated the photos. Did you take them all? Are they all from your neck of the woods?

My flower, BTW, is a passionfruit flower, which I am passionate about.



Namiko
Veteran
Veteran

User avatar

Joined: 13 Jun 2005
Age: 37
Gender: Female
Posts: 2,433

29 Dec 2005, 9:26 am

aylissa wrote:
Heck, I can't tell you how long it took me to find an avatar that was small enough to fit the guidelines and is just barely big enough to tell what it is. Sigh.


Aylissa, I found most of the avatars I've used on Google image searches for "avatar/s". I also came across a few sites for them, so if you'd like me to send them to you, go ahead and PM me. :)


_________________
Itaque incipet.
All that glitters is not gold but at least it contains free electrons.


Larval
Veteran
Veteran

User avatar

Joined: 15 Nov 2005
Gender: Female
Posts: 1,037

29 Dec 2005, 1:38 pm

hermit wrote:
Larval wrote:
[img:6bed9b1863]http://www.danasoft.com/sig/Pikachu\\\ssign.jpg[/img:6bed9b1863]

It didn't work for me though.


I tried embedding objects too, not in that format but since Vevivert said not Kosher I stopped trying.


Embedded objects? Hmm...

I don't really know php or BBcode at all - the text is just simple enough that I can get a basic idea of what each line does. Google helps me fill in the gaps.

I'd probably learn more but I'm not really into web site design (I know java and a splattering of javascript, though).