Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Getting rid of Gravatars …


Boone Gorges
Keymaster

@boonebgorges

Cool, I’m glad the first part worked!

Here’s a thrown-together-in-five-minutes filter to replace missing avatars with BP’s default mystery man. This probably won’t differentiate between user and group avatars, which you’ll have to sniff out of the $params array (in sort of the same way that I do with width and height). The basic idea is: if bp_core_fetch_avatar is not outputting any HTML, swap out the boolean false with the default mystery man.

`function bbg_no_avatar( $html, $params ) {
if ( !$html ) {
if ( $params )
$height = ‘ height=”‘ . $params . ‘”‘;

if ( $params )
$height = ‘ width=”‘ . $params . ‘”‘;

$default_image_url = WP_PLUGIN_URL . ‘/buddypress/bp-core/images/mystery-man.jpg’;
$html = ‘‘;
}

return $html;
}
add_action( ‘bp_core_fetch_avatar’, ‘bbg_no_avatar’, 10, 2 );`

Skip to toolbar