Not a developer? Go to MovableType.com

Plugin and Theme Directory

Gravatar v1.4

By Scott Boms
Posted September 20, 2008, in MT Tags, Templates, Widgets.

Details

Uses Gravatar's global recognized avatar system to output the correct gravatar image URL based on the commenter's email address.

This is an updated version of Tom Werner's original plugin and includes changes to the generated URL structure required to interact with the Gravatar service along with adding support for Movable Type 4.x.

Requirements

Gravatar account.

Compatibility

Movable Type versions: 4.3


Back

4 Comments

Dave Abrahams on May 12, 2009, 7:56 p.m. Reply

Neat, but how do I use it? I’m not sure where/how to place these tags. Can you offer any hints? An example would go a long way!

Scott Boms on May 12, 2009, 8:22 p.m. Reply

You can use the MTGravatar template tag anywhere within a MTComment context. For example, you can do the following which allows full customization over how the output is rendered as HTML.

<img src="<mt:Gravatar rating='g' size='36' 
  default='http://yourdomain.com/gravatar.gif'>" 
  height="36" width="36" 
  alt="<mt:CommentAuthor default="Anonymous">" 
  class="photo">

The plugin provides a few optional parameters which you can use as per the Gravatar API:

  • rating: g (default if excluded), pg, r, x
  • size: Dimensions for the Gravatar image. 80 (default), but any size from 1 to 512px can be used
  • default: Provide a fallback default image for users without a Gravatar. Requires a full URL.
  • border: Exactly what you would expect.

The simplest way you can implement the template tag is this:

<img src="<mt:Gravatar>" alt="<mt:CommentAuthor">

John Raymonds on October 1, 2009, 7:23 a.m. Reply

A specific template example for 4.25 — assuming it would even work with that version would be wonderful. Unfortunately my knowledge base is just large enough to get the install up and running and practically zero on customizing the default setup.

Scott Boms on October 1, 2009, 7:23 p.m. Reply

John - There should be no issues with the plugin on MT 4.25 and higher (I use it myself).

As far as examples go, If you want to use the code in the usage example above, you can do so as-is, obviously changing the image size if you want a larger/smaller size. That code would go into the Comment Detail Template Module to add a Gravatar for commenters though it’s pretty much up to you where exactly that goes depending on what you need.

Leave a Comment