Found you can create the address manually to return the image from Gravatar, and pass in parameters to force default and theme. Combined this in part with @Sudar's answer, as well as the code from pluggable.php as the admin page will grab the ID not email from $id_or_email, so a check needed to be added so the admin page shows the correct avatars.
function custom_get_avatar($avatar, $id_or_email, $size, $default, $alt) {
if ( is_admin() ) {
$email = '';
if ( is_numeric($id_or_email) ) {
$id = (int) $id_or_email;
$user = get_userdata($id);
if ( $user )
$email = $user->user_email;
} elseif ( is_object($id_or_email) ) {
// No avatar for pingbacks or trackbacks
$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) )
return false;
if ( !empty($id_or_email->user_id) ) {
$id = (int) $id_or_email->user_id;
$user = get_userdata($id);
if ( $user)
$email = $user->user_email;
} elseif ( !empty($id_or_email->comment_author_email) ) {
$email = $id_or_email->comment_author_email;
}
} else {
$email = $id_or_email;
}
$md5address = md5( strtolower( trim( $email ) ) );
return '<img width="'.$size.'" height="'.$size.'" src="http://www.gravatar.com/avatar/' . $md5address . '?d=retro&f=y" />';
}
else {
$md5address = md5( strtolower( trim( $id_or_email ) ) );
return '<img width="'.$size.'" height="'.$size.'" src="http://www.gravatar.com/avatar/' . $md5address . '?d=retro&f=y" />';
}
}
add_filter('get_avatar', 'custom_get_avatar', 10, 5);
Read more:
http://en.gravatar.com/site/implement/hash/
http://en.gravatar.com/site/implement/images/