How To Load Gravatar on the Fly


Sponsored Links




Gravatar become very popular image recognition, it’s small image displayed almost on my WordPress Themes. After acquired by Automattic, Gravatar seamless integrated in WordPress.com. And for WordPress.org users, there are some ways to displayed on their site/blog. We can manually insert code into themes or using Gravatar Plugins.

Load Gravatar on the fly - Marie Digby

Load Gravatar on the fly - Marie Digby

I will show you how to Load Gravatar Icon/Images on the fly using Javascript on your WordPress Comment, This code original design by Stephen Mcintyre. Let’s get started, you need to added this code in your comment form on comments.php

<img id="gravatar" src="http://www.gravatar.com/avatar/?s=80&d=wavatar&quot; width="80" height="80" alt="Gravatar" />

Image code below is the on the fly area on the Gravatar will be, and wavatar parameter is to displayed random wavatar, if there are no email available.

Next Step is added extra JavaScript to call MD5 gravatar and load it on the fly

<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/webtoolkit-md5.js"></script>
<script type="text/javascript">

var gravatar = document.getElementById('gravatar');

var email = document.getElementById('email');

email.onblur = function(e){
    var key = MD5(email.value);
    gravatar.src = 'http://www.gravatar.com/avatar/'+key+'?s=80&d=wavatar';
};

</script>

Please noted, you need to download webtoolkit-md5.js from WebToolkit and put it on your current themes folder. You need to put this code below your WordPress comment email field to make it work.

That’s all save it and you can test it your comment right now. For live tester, you can leave some comment on this site and check it, our Load Gravatar on the fly worked ;)

Subscribe to Full RSS Feed

RSS FeedIf you thing this article useful, please consider subscribing to our RSS Feed or e-mail updates and stay updated with us. You can also follow @WPTricksNet on twitter for latest updates.

About WP Tricks

We are WordPress Family, we collected and writed useful tips and tricks for you WordPress. We share it for you...

Related Tips and Trick from Local Data and on The Net

BF3: Your Own Photo In Battlog (Gravatar in Battlefield 3) - YouTube

your own picture to Battlelog.battlefield.com. Gravatar Tips 4 Noobs Xbox 360 HD | BF3 How To Fly Jet Plane Load more suggestions Read More

LOADING UP II « PlanetTrout

gravatar.com/97fc7b911437… planettrout.files.wordpre… Filed under: flies, fly tying step by steps Tagged typically marketed as indicating the "optimal load Read More

Jetpack for WordPress

Simple, concise site stats with no additional load on your server. Show a pop-up business card of your users’ Gravatar profiles in comments. Read More

Gravatar, one year later « Gravatar Blog

Wow it’s really been 1 year since Gravatar joined the it would help me keep tab on where I’m at when I fly 20 servers. 2 Database servers, 1 File server, 2 Load Read More

Rob's Blog » Categories » PHP » Resizing Images On The Fly With PHP

It wouldn't make sense for Gravatar to store an image of should avoid this method since it puts a lot of load on Link: Rob Keplin 洩 Resizing Images On The Fly With Read More


12 Responses to How To Load Gravatar on the Fly

  1. Good post. I see you have already integrated the code into your site, nice job! :)

    However, the process isn’t quite as simple as you put it in this article, and takes some tweaking (giving the email field the ‘email’ ID for example) to make it work.

    Very nice implementation though, this is exactly what I had in mind.

    • WP Tricks says:

      Thanks you Stephen, in our tutorial is what’s exactly I did in this site, why we not put email input? mostly comment email input is the same is on your tutorial. I will update the tutorial to tell everybody to put the javascript code below email input form on WordPress comment.

      Thanks you for you nicely tricks, this is what I really want and I hope this one useful for others….

  2. Pingback: Tweets that mention How To Load Gravatar on the Fly # WordPress Tricks & Tips -- Topsy.com

  3. Emily says:

    [...] This post was mentioned on Twitter by WordPress Tricks. WordPress Tricks said: RT @WPTricksNet How To Load Gravatar on the Fly http://goo.gl/fb/c8xeR #tricks #gravatar #hack #javascript #load [...]

  4. Amy says:

    Thanks you Stephen, in our tutorial is what’s exactly I did in this site, why we not put email input? mostly comment email input is the same is on your tutorial. I will update the tutorial to tell everybody to put the javascript code below email input form on WordPress comment.

    Thanks you for you nicely tricks, this is what I really want and I hope this one useful for others….

  5. Piseth says:

    This is good tips. thanks for sharing this little trick.

  6. Thanatos says:

    Thanks!
    Works like a charm!

  7. Lisa says:

    Is there a way to get rid of gravatar.com from wordpress and only use local avatars?

  8. Bojan says:

    Thanks!

  9. Hafid says:

    Nice tips…
    Well, I’ve question here, if I don’t sign account from gravatar.com… and when I leave my comment to other site, can my default gravatar load out there?
    Sorry my english not good.

  10. ray ban sale says:

    I leave my comment to other site, can my default gravatar load out there?
    Sorry my english not good.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>