PDA

View Full Version : gravatars vs favatars


derevaun
06-13-2005, 04:12 AM
I've been reading about gravatars and favatars:

http://www.noscope.com/journal/2004/12/favatars

Anybody using them? I added some code to functions.php to support them in really, really basic form:


if($comment_url != "") {
$comment_url = "http://$comment_url"; // i'm running for president...
$comment_url = str_replace("http://http://","http://",$comment_url); // you see?
$comment_name = "<a href='$comment_url' title='$lang_visit_homepage'>$comment_name</a>";
$grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($comment_email)."&size=24";
$urlParts = parse_url($comment_url);
$fav_url = $urlParts['scheme'].'://'.$urlParts['host'].'/favicon.ico';
}


...and then adding an image to each comment with $grav_url or $fav_url as the src attribute. My method for building the $fav_url string is pretty hacky and probably misses quite a few favicons, but it's a start. Of course, the fact that nobody visits my blog makes it a little difficult to actually get any use out of the code :)

Just wanted to toss that out there.

blinking8s
06-13-2005, 07:15 AM
lol...new to me, pretty neat concept, i have no use for it...but thanks for chuckin it up here

Joe[y]
06-13-2005, 11:32 AM
funky. i'm using the favicon option at my blog now!
great idea! cheers :D

fauxtog
07-07-2005, 03:46 PM
I have a gravatar account, but mine doesn't show up on your site derevaun. Oh, it took me a while to find your previous link. You might want to make it a little more prominent.

derevaun
07-08-2005, 05:08 AM
I think I set it to favatars only and stopped before figuring out how to make it do either one or the other. I switched it to gravatars and it works!

I've been puzzling over what to do with the previous link. I wanted to try something other than clicking the image, and ran out of room at the top. A redesign is iin order, but I should probably do something in the meantime. Thanks for bringing it up! :)

fauxtog
07-08-2005, 05:35 AM
The previous and next links would be fine in the same line where you have "...Today All 91 A month Whichever Bad cameras See also." Maybe in place of some of those. :-)

Could you post the updated code that you used?

wiphey
08-20-2005, 05:28 AM
I got this to work on my site with the gravatars, but it only works if the author enters his/her url in... I tried commenting out the favatar stuff but it still didn't work. I don't see what could be affecting it

wiphey
08-20-2005, 05:32 AM
nevermind i figured it out. the code should be like this:

if($comment_url != "") {
$comment_url = "http://$comment_url"; // i'm running for president...
$comment_url = str_replace("http://http://","http://",$comment_url); // you see?
$comment_name = "<a href='$comment_url' title='$lang_visit_homepage'>$comment_name</a>";
}
$grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($comment_email)."&size=24";
$urlParts = parse_url($comment_url);
$fav_url = $urlParts['scheme'].'://'.$urlParts['host'].'/favicon.ico';


the bracket was in the wrong place

Connie
08-20-2005, 07:14 PM
what the heck are you talking about?
:confused:
or am I too old to know about that?

wiphey
08-21-2005, 04:56 AM
umm... im not sure what you mean. you're asking what gravatars are??

example: http://kristin.pishdadi.com/index.php?showimage=10

www.gravatar.com
global recognized avatars, you sign up and your gravatar is pulled on websites you post comments on by your email address.

blinking8s
08-21-2005, 05:12 AM
i think its cool yo!

Connie
08-21-2005, 07:11 AM
yes, I wanted to know what GRAVATARS are....

derevaun
08-21-2005, 10:30 PM
I've updated, if not improved, the code in functions.php. First, I added a function that may or may not net more favicons, copied directly from http://www.peej.co.uk/projects/favatars.html


function getFavicon($url) {
$HTTPRequest = @fopen($url, 'r');
if ($HTTPRequest) {
stream_set_timeout($HTTPRequest, 0.1);
$html = fread($HTTPRequest, 4096);
$HTTPRequestData = stream_get_meta_data($HTTPRequest);
fclose($HTTPRequest);
if (!$HTTPRequestData['timed_out']){
if (preg_match('/<link[^>]+rel="(?:shortcut )?icon"[^>]+?href="([^"]+?)"/si',$html, $matches)) {
$linkUrl = html_entity_decode($matches[1]);
if (substr($linkUrl, 0, 1) == '/') {
$urlParts = parse_url($url);
$faviconURL = $urlParts['scheme'].'://'.$urlParts['host'].$linkUrl;
} elseif (substr($linkUrl, 0, 7) == 'http://') {
$faviconURL = $linkUrl;
} elseif (substr($url, -1, 1) == '/') {
$faviconURL = $url.$linkUrl;
} else { $faviconURL = $url.'/'.$linkUrl;
}
} else {
$urlParts = parse_url($url);
$faviconURL = $urlParts['scheme'].'://'.$urlParts['host'].'/favicon.ico';
}
$HTTPRequest = @fopen($faviconURL, 'r');
if ($HTTPRequest) {
stream_set_timeout($HTTPRequest, 0.1);
$favicon = fread($HTTPRequest, 8192);
$HTTPRequestData = stream_get_meta_data($HTTPRequest);
fclose($HTTPRequest);
if (!$HTTPRequestData['timed_out'] && strlen($favicon) < 8192) {
return $faviconURL;
}
}
}
}
return false;
}


...then changed some script to replace the gravatar with a favatar if there's one


if($comment_url != "") {
$comment_url = "http://$comment_url";
$comment_url = str_replace("http://http://","http://",$comment_url);
$grav_url="http://www.gravatar.com/avatar.php?gravatar_id=".md5($comment_email)."&amp;amp;size=16";
$fav_url = getFavicon($comment_url);
$av_url = $grav_url;
if ($fav_url) {
$av_url = $fav_url;
}
$comment_name = "<a href='$comment_url' title='$lang_visit_homepage' target='_blank'><img src='$av_url' />$comment_name</a>";
}


It's still flaky: where there is a favicon, I can reload and it alternates between returning the favicon url and returning false. I can't think of a way to test the presence of the gravatar before using it, so I'm stuck with inserting an image even if there's nothing for its src. But it's a start! Any insights?

wiphey
08-22-2005, 02:03 AM
I'm not a big fan of favatars, they're too small. A lot of people use gravatars now so the first version you made was simple for me to integrate.

Connie
08-22-2005, 08:58 AM
Please,

do these things in AddOns, users will not be able to follow that when they update PixelPost

we have AddOns there, we do not want Hacks and modifications anymore as the support for users will be too difficult in case they update the official version...

because of compatibility, do these things in AddOns:rolleyes:

Joe[y]
08-22-2005, 05:37 PM
could have sworn there was a favator addon i used a while back which worked super! till i accidently lost it updating version.

derevaun
08-26-2005, 07:12 AM
OK, I've made an addon for gravatars : http://forum.pixelpost.org/showthread.php?p=13411 . If there's interest, I'll try to make one for favatars too.