Automattic, the company behind WordPress, recently acquired Gravatar. In case you don’t know, gravatars—or “globally recognized avatars”—are images that you can associate with an email address, so a picture of your choice can appear alongside your comments on many others’ blogs.
Gravatar already provides a simple WordPress plugin, but it suffers from a common plugin problem: if you add its “gravatar” function to your comments template, you either have to wrap it in a function_exists check, or you’ll get a fatal error when you deactivate the plugin.
My gravatar plugin lets you use WordPress’s action hook callback system, so it just disappears when the plugin is deactivated.
How it works:
If you just want to display a commenter’s gravatar image, just add
<?php do_action('gravatar') ?>
to the appropriate place in your WordPress comments.php template. By default, it will generate a gravatar image.
But you can customize it as much as you want, by passing an array of arguments to the ‘gravatar’ action hook. On my blog I’ve done the following:
<?php do_action('gravatar', array('div_class' => 'gravatar', 'return' => 'div', 'default' => get_bloginfo('stylesheet_directory') . '/images/default_gravatar.png', 'rating' => 'PG')) ?>
That tells the plugin to wrap the gravatar image in a div with a class of “gravatar”, using a default gravatar image located in my theme’s images directory, and returning only PG-rated gravatars.
Here is a complete list of arguments you can pass to the gravatar hook:
alt: Text for the alt attribute of the gravatar image. border, b: An argument you can pass to the gravatar server, the “border” is a hex color to be generated around the gravatar image. comment_author_email: The email on which to base the gravatar. By default, the plugin gets this from the comment’s author email. default, d: The default image to use if no gravatar is available. div_class: A class for the div element surrounding the gravatar, if you’ve set “return” to “div.” echo: Whether to echo the result (true by default). If you wanted to assign the gravatar image URL to a variable named $path, you would do the following:<?php $path = apply_filters('gravatar', array('echo' => false, 'return' => '')); ?>
gravatar_id, g: The gravatar id. Usually this is generated from the commenter’s email, but if you want you can pass it directly. img_class: A class for the gravatar img element. rating, r: The rating of allowed gravatar images, as explained at the gravatar website. Optinos are G, PG, R, and X. return: What to return. By default, this is an image element (”img”). You can also select “div” for a div element around an image, or just return the path to the image with “return” set to “”. pattern: Any string containing %s; the plugin will return that string, replacing %s with the gravatar image path.
For example, setting “pattern” to would return the gravatar image in a span element.
size, s: The size of the gravatar image, in pixels. Currently it can range between 1 and 80.Download
Filosofo Gravatar Plugin 1.5 | March 15, 2007
If you have problems, questions, or suggestions, please leave a comment below or open a ticket in my support forum.
See some of the other WordPress plugins I’ve created.
Like this plugin? Is it worth a latte?
This month I have received $40.00 for my plugin coding work, which is about $0.02 per download.

[...] Filosofo Gravatars [...]
[...] WordPress Plugin from the Gravatars site, or chose from the Easy Gravatars WordPress Plugin or WordPress Gravatar Plugin by Il Filosofo. Both have excellent features and [...]
[...] Filosofo’s Wordpress Gravatar Plugin [...]
[...] Filosofo Gravatars (for displaying a commenter’s gravatar when applicable, although I may soon be switching to something using mybloglog instead.) [...]
[...] Filosofo Gravatars [...]
[...] Filosofo Gravatars [...]
[...] 57. Filosofo’s Wordpress Gravatar Plugin The plugin fixed my issue of not being able to get gravatars to work with my blog. If you’re looking to put gravatars on your site in the comment section, Filosofo’s code is well written. Share And Enjoy //Random iframe content- © Dynamic Drive (www.dynamicdrive.com) //For full source code, and Terms Of use, visit http://dynamicdrive.com //This credit MUST stay intact for use var ie=document.all&&navigator.userAgent.indexOf(”Opera”)==-1 var dom=document.getElementById&&navigator.userAgent.indexOf(”Opera”)==-1 //Specify IFRAME display attributes var iframeprops=’width=500 height=225 marginwidth=”0″ marginheight=”0″ hspace=”0″ vspace=”0″ frameborder=”0″ scrolling=”no”‘ //Specify random URLs to display inside iframe var randomcontent=new Array() randomcontent[0]=”http://eventurebiz.com/blog/wp-content/themes/techland-10/random/r_1.htm” randomcontent[1]=”http://eventurebiz.com/blog/wp-content/themes/techland-10/random/r_2.htm” randomcontent[2]=”http://eventurebiz.com/blog/wp-content/themes/techland-10/random/r_3.htm” //No need to edit after here if (ie||dom) document.write(”) function random_iframe(){ if (ie||dom){ var iframeobj=document.getElementById? document.getElementById(”dynstuff”) : document.all.dynstuff iframeobj.src=randomcontent[Math.floor(Math.random()*randomcontent.length)] } } window.onload=random_iframe Related Posts Hack WordPress [...]
[...] Gravatars - Automattic, the company behind WordPress, recently acquired Gravatar. In case you don’t know, gravatars—or “globally recognized avatarsâ€â€”are images that you can associate with an email address, so a picture of your choice can appear alongside your comments on many others’ blogs. [...]
wordpress…
Its just great! There are so many sites, which offer free wordpress themes. And if you are searching for a real unique design, there are thousands of programmers and designers which offer their work. Nice to be part of the great wordpress-community. :-…
[...] Filosofo Gravatars [...]