Gravatar support was added into the WordPress core in 2.5. You could toggle them and chose what rating level (G/PG/PG13/R/X) you wanted to allow, but you couldn’t easily change the default avatar for users without a custom Gravatar. That is, until recently.

Earlier this month, Ryan committed a modified version of a patch I wrote. It adds a list of default avatars to the bottom of the discussion options page and has already been added to WordPress.com.

What does this mean for theme developers? Well, this new feature also allows you to define custom default avatars that better match your theme. Here is some example code that you would add to your theme’s functions.php:

<?php

add_filter( 'avatar_defaults', 'mytheme_addgravatar' );

function mytheme_addgravatar( $avatar_defaults ) {
	$myavatar = get_bloginfo('stylesheet_directory') . '/images/avatar.png';
	$avatar_defaults[$myavatar] = 'My Theme';
	return $avatar_defaults;
}

?>

That will add a new default avatar option to the bottom of the user’s settings page.