Disable Gravatar in WordPress and fetched Avatar Locally

To disable Gravatar in WordPress and fetched Avatar Locally you need to follow simple steps.

  1. Go to admin section.
  2. Go to setting-> Discussion
  3. Go to bottom under Avatar section choose “Mystery Person”, if you want image other then mystery person download  Add New Default Avatar plugin which willAdd new option to the Default Avatar list.
  4. Done

If there are still some instance where Gravtar images are displayed then add the following line of code in your functions.php file.

// Remove Gravatar
function bp_remove_gravatar ($image, $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir) {

$default = get_stylesheet_directory_uri() .’/images/avatar.jpg’;

if( $image && strpos( $image, “gravatar.com” ) ){

return ‘<img src=”‘ . $default . ‘” alt=”avatar” class=”avatar height=”40px” width=”40px”” />’;
} else {
return $image;

}

}
add_filter(‘bp_core_fetch_avatar’, ‘bp_remove_gravatar’, 1, 9 );

function remove_gravatar ($avatar, $id_or_email, $size, $default, $alt) {

$default = get_stylesheet_directory_uri() .’/images/avatar.jpg’;
return “<img alt='{$alt}’ src='{$default}’ class=’avatar avatar-{$size} photo avatar-default’ height='{$size}’ width='{$size}’ />”;
}

add_filter(‘get_avatar’, ‘remove_gravatar’, 1, 5);

function bp_remove_signup_gravatar ($image) {

$default = get_stylesheet_directory_uri() .’/images/avatar.png’;

if( $image && strpos( $image, “gravatar.com” ) ){

return ‘<img src=”‘ . $default . ‘” alt=”avatar” class=”avatar” width=”40″ height=”40″ />’;
} else {
return $image;
}

}
add_filter(‘bp_get_signup_avatar’, ‘bp_remove_signup_gravatar’, 1, 1 );

Reference

http://www.adminblog.com/wordpress-remove-gravatar/

 

#Tags

get rid of gravatar wordpress

custom avatar wordpress

change wordpress avatar without gravatar

simple local avatars wordpress

wordpress change user profile picture

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s