Scare Your Visitors with this JavaScript Gravatar Plugin

See the Demo

Download the Source Code




Tournology Blog Comment Form

Here’s a use case. An unregistered visitor visits your blog, and decides that your content is so good that it merits a comment! Congratulations, you’ve fooled them! Now you can twply their account details for $1200 on Sitepoint! Just kidding. But generally, when you visit a blog’s commenting section (such as the Tournology Blog shown above), you’ll see a simple form to authenticate you’re not a spammer, generally including (among other things) an e-mail address field.




Tournology Blog Comment Form With Gravatar

Well, since they’re typing their e-mail address, wouldn’t it be cool if we could show them their gravatar right there, inline with the blog comment form? Well, that’s now possible with my new JavaScript Gravatar Plugin! It doesn’t have any server side language dependencies.




Gravatar Signup Page

Hell, gravatar.com could even use this to improve the user experience of registering your e-mail account. Right now it does a full page refresh and doesn’t even show you a preview!


See the Demo

Download the Source Code


Licensing

Licensed under the WTFPL, as highly recommended by Isaac Schleuter (see discussion).


JavaScript Dependencies:

  • Requires jQuery (Feel free to port and post a link!)
  • Requires md5.js


Example Usage:

Easiest form, onblur of email text input field:

$('#emailTextField').blur(function(event)
{
    $(this).after($.gravatar($(this).val()));
});

Showing all options, again onblur of email text input field.

$('#email').blur(function(event)
{
    $('body').append($.gravatar($(this).val(), {
        // integer size: between 1 and 512, default 80 (in pixels)
        size: 200,
        // maximum rating (in order of raunchiness, least to most): g (default), pg, r, x
        rating: 'pg',
        // url to define a default image (can also be one of: identicon, monsterid, wavatar)
        image: 'identicon'
    }));
});

Update: This script has been moved to Github.

This entry was posted in JavaScript, Projects and tagged , . Bookmark the permalink. Both comments and trackbacks are currently closed.
  • If you found this article useful, you should subscribe to my feed (or get an e-mail). I'm also on Twitter and GitHub.
  • About the Author

    Zach Leatherman is a Professional Front End Engineer. He loves building for the web, and has been contributing to the community through his blog since February 2007. Despite his propensity for software, he has a Bachelors degree in Computer Engineering and is currently on the User Experience Team at Union Pacific Railroad. The views expressed on this website do not represent the views of his employer.

    He enjoys spending time with his beautiful wife Traci and their two Great Danes, Roxie and Ella. They also have a cat, a rabbit, goldfish, and one or more tarantulas. Read more »

6 Comments

  1. Posted January 9, 2009 at 1:01 am | Permalink

    hey i want a downloadable version of alarmd

    so we can use our own computer songs

    and not be dependent on the internet (sometimes internet goes down)

    aye

  2. Zach Leatherman
    Posted January 9, 2009 at 1:02 am | Permalink

    Added this to the official jQuery plugin repository:
    http://plugins.jquery.com/project/gravatar

  3. Zach Leatherman
    Posted January 9, 2009 at 1:08 am | Permalink

    Well, it’s certainly nice to see that someone reads my posts.

    If I ever get bored, I might look at porting to AIR. Or if Gears ever adds file access. But, generally these things are managed on the Google Code page.

  4. Adam
    Posted January 9, 2009 at 1:11 pm | Permalink

    But you don’t have it set up on this blog! I wanted to see it in action besides the demo.

  5. Posted May 8, 2011 at 1:11 am | Permalink

    This is very cool! :)

  6. Traplift Gids
    Posted September 30, 2011 at 6:53 pm | Permalink

    This plugin is really cool i scared the hell out of some people with it on my wordpress blog.

One Trackback

  1. [...] Comments Adam on Scare Your Visitors with this JavaScript Gravatar PluginZach Leatherman on Scare Your Visitors with this JavaScript Gravatar PluginZach Leatherman on Scare [...]