Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: How to disable Gravatar completely?


BuddyPresser
Participant

@buddypresser

Ok finally fixed it with some core code hacking :P

Here’s my patch solution for anyone wanting to replace default avatars and disable gravatars:

in bp-core-avatars.php, function bp_core_fetch_avatar():

I replaced this:

$gravatar = apply_filters( 'bp_gravatar_url', 'https://secure.gravatar.com/avatar/' ) . md5( $grav_email ) . '?d=' . $default_grav . '&s=' . $grav_size;

with this line:

$gravatar = get_bloginfo('template_directory') . '/images/new-default.jpg';

then in bp-core-templatetags.php, function bp_get_signup_avatar():

replaced this line:

return apply_filters( 'bp_get_signup_avatar', '<img src="' . $gravatar_url . md5( $_POST['signup_email'] ) . '?d=' . $default_grav . '&s=' . $size ) . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />';

with these:

$default_grav = get_bloginfo('template_directory') . '/images/new-default.jpg';
return apply_filters( 'bp_get_signup_avatar', '<img src="' . $default_grav . '"' ) . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />';

Also added a filter to functions.php as it was sometimes returning an image tag with an empty src (broken avatars) – it checks for the empty tag and replaces it with the default:

Note: BP_AVATAR_DEFAULT was defined in my bp-custom.php file.

function no_empty_avatar($avatar_link) {
if ( strpos( $avatar_link, "src=''" ) ) {
$avatar_link = str_replace("src=''", "src='" . BP_AVATAR_DEFAULT . "'", $avatar_link );
}
return $avatar_link;
}
add_filter( 'bp_core_fetch_avatar', 'no_empty_avatar' );

Hope this helps someone in future..

If anyone has a better solution without hacking the core files, please let me know!

Skip to toolbar