Replace Gravatar with Local Image
add_filter( 'get_avatar', 'bubdev_get_local_avatar', 10, 5 );
/**
* Replace Gravatar
*
* Replaces specific user gravatar with local image. Disables all other user
* gravatars on the frontend.
*/
function bubdev_get_local_avatar( $avatar, $id_or_email, $size, $default, $alt ) {
if ( is_admin() ) return;
$user_mail = 'some@email.net';
$att_url = wp_upload_dir()['baseurl'] . '/someone.jpg';
$att_id = attachment_url_to_postid( $att_url );
$att_alt = get_post_meta( $att_id, '_wp_attachment_image_alt', true );
if ( $id_or_email && $id_or_email === $user_mail ) {
$markup = '<img src="' . $att_url . '" class="avatar photo" width="' . $size . '" height="' .
$size . '" alt="' . $att_alt . '">';
return $markup;
}
return false;
}
Genesis Framework Gravatar Modifications
//* Modify the size of the Gravatar in the author box
add_filter( 'genesis_author_box_gravatar_size', 'bub_author_box_gravatar' );
function bub_author_box_gravatar( $size ) {
return 144;
}
//* Modify the size of the Gravatar in the entry comments
add_filter( 'genesis_comment_list_args', 'bub_comments_gravatar' );
function bub_comments_gravatar( $args ) {
$args['avatar_size'] = 96;
return $args;
}