Custom buddypress avatars

Custom buddypress avatars

I’ve got a project over at that is powered by the buddypress framework. While technically a plugin developed for WordPress, it’s really a whole lot more robust than your typical plugin.

That being said, default avatars (from any web application) are high on the list of bad site aesthetics. Really makes things look unfinished and unpolished in my opinion. The buddypress set of icons is now exception:

Some user avatars:

And some group avatars:

Not cool 🙂 Fortunately there is a very easy fix for this. So, let’s create your very own (default) custom buddypress avatars. Start by making your way over to the (buddypress) functions.php file and plug in the following php code:

[php]function myavatar_add_default_avatar( $url )

return get_stylesheet_directory_uri() .’/_inc/images/default-grav.png’;
add_filter( ‘bp_core_mysteryman_src’, ‘myavatar_add_default_avatar’ );

function my_default_get_group_avatar($avatar) {

global $bp, $groups_template;

if( strpos($avatar,’group-avatars’) ) {

return $avatar;

else {
$custom_avatar = get_stylesheet_directory_uri() .’/_inc/images/default-group-avatar.png’;

My default avatar is named “default-grav.png”. You’ll have to change that to whatever the name of you file is and be sure the URL path is correct.

And for group avatars:

[php]if($bp->current_action == "")
return ‘<img width="’.BP_AVATAR_THUMB_WIDTH.’" height="’.BP_AVATAR_THUMB_HEIGHT.’" src="’.$custom_avatar.’" class="avatar" alt="’ . attribute_escape( $groups_template->group->name ) . ‘" />’;
return ‘<img width="’.BP_AVATAR_FULL_WIDTH.’" height="’.BP_AVATAR_FULL_HEIGHT.’" src="’.$custom_avatar.’" class="avatar" alt="’ . attribute_escape( $groups_template->group->name ) . ‘" />’;
add_filter( ‘bp_get_group_avatar’, ‘my_default_get_group_avatar’);[/php]

Again, you’ll have to “default-group-avatar.png” to whatever your file name is, check the URL path and fill in any specs as needed. That’s it!