Skip to content

Instantly share code, notes, and snippets.

@mjsdiaz
Last active September 9, 2018 00:25
Show Gist options
  • Save mjsdiaz/3cb4b0fdf5889dbdac78ae0876ef6616 to your computer and use it in GitHub Desktop.
Save mjsdiaz/3cb4b0fdf5889dbdac78ae0876ef6616 to your computer and use it in GitHub Desktop.
Use default avatars for author and others in comments
<?php // Do not add this to your functions.php.
/* Use default avatars for author and others in comments */
add_filter( 'get_avatar', 'agf_custom_avatars', 10, 3 );
function agf_custom_avatars( $avatar, $size ) {
if ( is_admin() ) {
$size = '48';
return $avatar;
}
$size = '96';
$author = get_comment_author();
if ( 'Shea' === $author ) {
$avatar_url = get_stylesheet_directory_uri() . '/images/red-icon-155.png';
} else {
$avatar_url = get_stylesheet_directory_uri() . '/images/bw-icon-155.png';
}
$avatar = '<img src="' . $avatar_url . '" class="avatar avatar-' . $size . ' photo" width="' . $size . '" height="' . $size . '" />';
return $avatar;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment