Announcing EEGravatar.

Posted by Les on Tuesday, July 27, 2004 at 10:35 PM. Read 12070 times. Tags: ,
{name} pic

I’ve written my first plugin in PHP for ExpressionEngine called EEGravatar. It’s basically a simple way of allowing for avatars in your entries or comments using a centralized avatar hosting service called, oddly enough, Gravatar. If you’d like an avatar image of your own for the comments, just go to the Gravatar site and register using the same email address you use to post comments here and upload an avatar no bigger than 80x80 pixels. Once it’s approved it’ll start showing up in your comments automatically.

If you’d like to use EEGravatar on your own ExpressionEngine blog you can download a copy by clicking here. There is also a plugin available for MovableType and WordPress. There’s also a hack for TextPattern.

Update: I’ve duplicated the docs included in the plugin in the extended entry.

Updated Update: Here’s a little Gravatar button I made if you want to use it:

Version Update: The plugin has been updated to EE Gravatar 1.2 for use with ExpressionEngine 1.1 and is now a single tag plugin. See the updated docs in the plugin or down below for examples.

Version Update: The plugin has been updated to EE Gravatar 1.3 (the Lisa-Jill version). Minor change to output for XHTML compliance.

Version Update 10/2/04: EEGavatar is now up to version 1.4. Can now use {name} in addition to email as the one required parameter for use in Member Profiles and other places where the email parameter breaks the plugin. See documentation below for more information.

Documentation

The EE Gravatar Plugin allows you to easily insert a “globally recognized avatar” image from Gravatar (http://www.gravatar.com/).

This plugin requires at a bare minimum one of two possible parameters depending on where you wish to use it. The first option is a user’s email address and the second option is a user’s screen name. The reason for this is so the plugin can be used in situations where one or the other parameter won’t return the proper result. It is recommended that you use email for comment and entry loops and name for display in member profile templates, but feel free to experiment. Here’s the two minimum required uses:

<img src="{exp:gravatar email="{email}"}" /> -- For use in comment or entry loops.

<
img src="{exp:gravatar name="{name}"}" /> -- For use in templates such as Member Profiles where email won't work as expected.

== OPTIONAL PARAMETERS ==

default="http://www.somesite.com/someimage.jpg"

Defines a default avatar if there isn’t one associated with the email address or if it exceeds the rating.

rating="[G | PG | R | X]”

Allows you to limit gravatars to the appropriate rating. Anything exceeding the rating will use the default (if supplied) or not display.

size="[1..80]"

Allows you to define how big the gravatar will be in pixels. Any size other than 80 will cause the original gravatar image to be downsampled using bicubic resampling before output

border="[hex color]”

Puts a border of the specified color around the gravatar.

== POSSIBLE EXAMPLES ==

Here’s a few examples that you might use:

<img src="{exp:gravatar email="{email}" rating="PG"}" />

Only displays gravatars of PG rating or lower.

<img src="{exp:gravatar email="{email}" rating="R" size="40" border="FF0000"}" />

Displays 40x40 pixel gravatars of R rating or lower with a red border around them.

<img src="{exp:gravatar email="{email}" size="70" default="http://www.somesite.com/someimage.jpg"}" alt="Picture of {name}" title="{name}" class="avatar" />

Displays gravatars of 70x70 pixels or a default graphic for users without a gravatar. Puts the user’s name in the alt and title tags and styles the image using a class called “avatar.”

<div class='profileTitle'><img src="{exp:gravatar name="{name}" size="80" rating="R"}" border="0" style="float: left; margin: 0; padding: 6px;" alt="{name} pic" title="{name}" />{name}</div>
<
p>{lang:member_group}&nbsp; <b>{member_group}</b></p>

The above is a snippet of code from my Public Member Profile template showing how to insert a gravatar into the member listings for your site.

== Change Log ==

V1.4 - Added {name} parameter as alternate to {email} for use in situations where {email} breaks the plugin such as Member Profiles.

V1.3 - Changed & to & for XHTML validation compliance.

v1.2 - Made {email} into a parameter along for single tag usage for EE 1.1 release.

v1.1 - Minor bug fix.

v1.0 - Initial Release

Comments:

Page 2 of 4 pages  <  1 2 3 4 >

Tom Werner United States Posted on 07/28/2004 at 02:34 PM

Tom Werner pic

Les, in order for the “default” attribute to work properly, you should be url encoding the passed in url. In PHP you can do it with urlencode().

For those that are interested, email addresses are used as the primary key for gravatars for several reasons. Foremost, by basing it on email address, they can be implemented on weblogs without any additional information requirements. This means past entries will also get gravatars, if the proper email address was given. I made gravatars as uncomplicated as possible, to ease implementation. Creating a separate ID that would have to be given on comment forms would require much more work for implementors, increasing the barrier to entry, and making the whole system a big hassle. Additionally, for sites that use something like TypeKey for user authentication, gravatars will also automatically become authenticated.

If you are worried about anonymity or spam, you can always create a yahoo or hotmail account to use as your email address on gravatar. As the privacy policy states, I will never spam you, nor will I sell, distribute, or otherwise make any emails available to any third parties.

GeekMom United States Posted on 07/28/2004 at 03:34 PM

GeekMom pic

Wow, there are some pretty cool avatars ‘round here ...

("who")

Les United States Posted on 07/28/2004 at 04:17 PM

Les pic

Spocko, I’d imagine it’s probably case sensitive as I’m not doing anything to force it one way or the other at this point. Email addresses are supposed to be lowercase only and currently the plugin assumes it is, though I could put in code to force it to lowercase before sending it to the folks at Gravatar if necessary. I don’t recall if the Gravatar site said anything about their side being case sensitive, but I’ll check.

DeadScot, for the moment this won’t have any impact on the forum avatars as those are built into that package. I have the same issues as I also use multiple email addresses and I think there may be some room for improvement in that regard, but as Tom points out this is currently the simplest solution. I don’t recall where I read it, but someone brought up the idea of developing a non-centralized distributed avatar solution that sounded like it might be a neat idea even if I haven’t a clue how to go about doing it. It would be fun to write a plugin for, though.

Etan, it’s simple enough: .avatar {float: right; margin-top: 2px; margin-left: 10px;} and then I added a min-height: 84px; to the comment DIV to make sure it’s always tall enough to hold the avatar up to the maximum size allowed, though I suppose if you were using a smaller sized avatar you could decrease the min-height as necessary.

Chris, thanks. Had I known you were working on one as well I probably would’ve waited for some other project, but once I got started on it it became a little mini-obsession and I had to finish it.

Tom, I actually did use the urlencode function and that seems to have been the problem as it wasn’t encoding properly for reasons I’m not sure about. When I took out the urlencode and just passed along the raw URL it started working so for the moment my plugin isn’t encoding the URL at all. Let me know if that’s a problem, but your service seems to be dealing with it just fine.

 Signature 

All I know is the wine lasts longer when you don’t gotta share it with someone
All I know is my steak tastes better when I take my steak tastes better pill
-- I Feel Fantastic, Jonathan Coulton

Les United States Posted on 07/28/2004 at 04:25 PM

Les pic

Spocko, I edited your email address here and made it lowercase and it’s working now so the answer is, yes - it is case sensitive.

I’ll modify the plugin so it forces lowercase in the future.

 Signature 

All I know is the wine lasts longer when you don’t gotta share it with someone
All I know is my steak tastes better when I take my steak tastes better pill
-- I Feel Fantastic, Jonathan Coulton

***Dave United States Posted on 07/28/2004 at 04:31 PM

***Dave pic

Jeez.  My icon looks pretty dull by comparison.

Spocko United States Posted on 07/28/2004 at 04:40 PM

Spocko pic

Thanks Les!

Tek United States Posted on 07/28/2004 at 08:47 PM

Tek pic

Wooo, I have one!

decrepitoldfool United States Posted on 07/28/2004 at 09:12 PM

decrepitoldfool pic

It’s really neat to compare what I imagined everyone would do with the gravatar actually chosen.  Cool feature, Les!

‘cept seeing my gravitar too many times on a thread will be a clue for me to quiet’n down a bit ‘n let others have a say.

John Hoke United States Posted on 07/28/2004 at 09:50 PM

John Hoke pic

Tom Werner created a new version of the MT plugin for gravatar for those of us who were kinda in hell.

I now have them enabled on my site, and Loving the way they came out smile

Now all i need is a better avatar… this is just one I grabed because it was handy and the right size ... feh!

-j-

deadscot United States Posted on 07/28/2004 at 10:29 PM

deadscot pic

Geekmom’s and DOF’s Gravatars are exactly how I had the two of them pictured in my mind all along.

captcha = ‘les’ Now isn’t that special.

Les United States Posted on 07/28/2004 at 10:33 PM

Les pic

I’ve been wondering how long it would be before someone started noticing I had made changes to the captcha word list to include some items related to the blogs here. grin

 Signature 

All I know is the wine lasts longer when you don’t gotta share it with someone
All I know is my steak tastes better when I take my steak tastes better pill
-- I Feel Fantastic, Jonathan Coulton

Spocko United States Posted on 07/28/2004 at 11:02 PM

Spocko pic

Wow! Tek looks hot! cool grin

Les United States Posted on 07/28/2004 at 11:05 PM

Les pic

That’s because Tek IS hot. In my fevered dreams she actually stops to give me the time of day when I ask.

wink

 Signature 

All I know is the wine lasts longer when you don’t gotta share it with someone
All I know is my steak tastes better when I take my steak tastes better pill
-- I Feel Fantastic, Jonathan Coulton

DJ Europe Posted on 07/29/2004 at 08:13 AM

DJ pic

Looks cool… Have you emailed Gravatar about your plugin? they’re not listing it.

Its all implemented all i need now is for someone to test it

DJ

Les United States Posted on 07/29/2004 at 08:41 AM

Les pic

I’ve spoken with Tom about it and he’s offered to include info about it on the Gravatar site (I even sent him the little button I whipped up for it over in the sidebar).

I’m holding off on having him list it at the moment only because Chris Ruzin has developed a version of this plugin as well and has already managed to implement a caching system into it whereas I’m still learning how to do such a thing. Once Chris gets the bugs worked out of his version I think it will end up supplanting my own as the superior option so rather than have Tom go through the trouble of listing mine only to have Chris’ replace it I’m going to hold off until Chris finishes his and see how he wants to handle things.

 Signature 

All I know is the wine lasts longer when you don’t gotta share it with someone
All I know is my steak tastes better when I take my steak tastes better pill
-- I Feel Fantastic, Jonathan Coulton

OB United States Posted on 07/29/2004 at 10:28 AM

OB pic

Interesting… my avatar was given a PG rating.  For those who might not know, She’s Kali, a Hindu goddess - and this version is her Crone (death) aspect.  I’m tempted to submit one of the Virgin Mary just to see what rating the Christian Crone gets ("… now and at the hour of our death...").

("distance" - what I need to put between me & this keyboard, and get my ass to work!)

 Signature 

Invisible friends are for children and psychopaths.

Les United States Posted on 07/29/2004 at 10:56 AM

Les pic

Well, she is stomping on someone while holding some poor fellow’s head in one of her hands. I suppose it could be considered a bit on the violent side.

grin

 Signature 

All I know is the wine lasts longer when you don’t gotta share it with someone
All I know is my steak tastes better when I take my steak tastes better pill
-- I Feel Fantastic, Jonathan Coulton

DJ Great Britain (UK) Posted on 07/29/2004 at 11:44 AM

DJ pic

LOL  I’ve been rated PG too.... hmmm wonder if anyone has anything harsher?

deadscot United States Posted on 07/29/2004 at 12:43 PM

deadscot pic

Oh yeah!

Spocko wrote:

Wow! Tek looks hot![/Quote]
Les wrote:

That’s because Tek IS hot. In my fevered dreams she actually stops to give me the time of day when I ask.

I’d read Tek’s blog more often but they only deliver dry ice here once a week.

captcha = ‘couple’ One can dream.

Tek United States Posted on 07/29/2004 at 03:29 PM

Tek pic

Thanks guys.

You are giving me a complex. wink

I need to see if I want to try this on my blog.  I have so many plug-ins however that I getting a bit para.

On top of it one of my PC’s is not acting right and I think I need to fix it.

Mike United States Posted on 07/31/2004 at 12:52 AM

Mike pic

hmmmm… I have no part in this conversation… oh well lets see if my wholesome G-rated Gravatar is working, eh?

DJ Great Britain (UK) Posted on 07/31/2004 at 03:02 AM

DJ pic

Thats a G? Is a monkey holding a gun. How is that less harmful than a God or half a stuck up finger?

Les United States Posted on 07/31/2004 at 12:17 PM

Les pic

Hey now, that finger might be loaded!

 Signature 

All I know is the wine lasts longer when you don’t gotta share it with someone
All I know is my steak tastes better when I take my steak tastes better pill
-- I Feel Fantastic, Jonathan Coulton

DJ Great Britain (UK) Posted on 07/31/2004 at 12:32 PM

DJ pic

true wink But i promise it isn’t

John Hoke United States Posted on 07/31/2004 at 02:39 PM

John Hoke pic

Is a monkey holding a gun. How is that less harmful than a God or half a stuck up finger?

Well, Hmm… Bush is a chimp ... therefore all monkeys are to be worshiped and praised here in A’Mor’ica

Wait! There’s Bush’s WMD --- Weapon of Monkey Distruction!!!

Back to your regularly scheduled medication ... big surprise

-=j=-

Page 2 of 4 pages  <  1 2 3 4 >

Name:

Email:

Location:

URL:

Smileys


Remember my personal information

Notify me of follow-up comments?

Submit the word you see below:


<< Back to main