Last active
September 9, 2018 00:25
-
-
Save mjsdiaz/3cb4b0fdf5889dbdac78ae0876ef6616 to your computer and use it in GitHub Desktop.
Use default avatars for author and others in comments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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