Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: surprising avatar behavior

So – in 1.1 BuddyPress does not query the database to fetch avatars, it expects them to be in specific folders and with specific names.

Likely what it happening is the permissions on the folders denied BuddyPress the access it needed to move avatars around and into the format/location needed for 1.1. Most of the problems will be related to group avatars mixing up with user avatars, as they were in the same folder for 1.0.

The quickest option is to remove the /wp-content/blogs.dir/1/files/avatars/ directory and let BuddyPress rebuild your avatars as people upload again. Anyone who has a Gravatar will revert back to that image, so not all will be lost.

Other than that, you can use this code below to place group avatars in the correct place, so they don’t conflict with user avatars (this normally runs on upgrade). Make sure the permissions on the avatar folder allow for BuddyPress to move files around.

function move_group_avatars() {
/* On upgrade, handle moving of old group avatars */
$groups = groups_get_all();

foreach ( $groups as $group ) {
/* Don't fetch and move gravs, default images or empties */
if ( empty($group->avatar_thumb) || strpos( $group->avatar_thumb, 'gravatar.com' ) || strpos( $group->avatar_thumb, 'identicon' ) || strpos( $group->avatar_thumb, 'none-thumbnail' ) )
continue;

$start = strpos( $group->avatar_thumb, 'blogs.dir' );

if ( false !== $start ) {
$avatar_thumb = WP_CONTENT_DIR . '/' . substr( $group->avatar_thumb, $start, strlen( $group->avatar_thumb ) );
$avatar_full = WP_CONTENT_DIR . '/' . substr( $group->avatar_full, $start, strlen( $group->avatar_full ) );

if ( !file_exists( $avatar_thumb ) || !file_exists( $avatar_full ) )
continue;

$upload_dir = groups_avatar_upload_dir( $group->id );

copy( $avatar_thumb, $upload_dir['path'] . '/' . basename($avatar_thumb) );
copy( $avatar_full, $upload_dir['path'] . '/' . basename($avatar_full) );

unlink( $avatar_thumb );
unlink( $avatar_full );
}
}
}
add_action( 'plugins_loaded', 'move_group_avatars' );

Put that somewhere so it can run, maybe temporarily paste it at the top of bp-core.php, then remove it when you are done.

Skip to toolbar