Skip to:

Re: Avatar Upload Issues

Boone Gorges


I was experiencing exactly the same problem that Tracedef describes after an upgrade from BP 1.0.3 to 1.1.3 (and WPMu 2.8.4a to 2.8.6, if it matters). Some users who’d been group admins (and uploaded group avatars) before the upgrade saw one of the group avatars on their profile page instead of their profile avatar. And when they tried to change the profile avatar, they were able to walk through the uploading and cropping process, but the group avatar was still displayed. It’s possible that the problem is only limited to users whose initial avatars were gravatars.

A bit of poking around showed that the portion of bp-core/bp-core-avatars.php that looks for avatar files in the user’s avatar directory (the first segment pasted below) was returning multiple filenames and settling on the final one, which happened in all cases to be group avatars rather than personal ones (even though personal replacement avatars had been subsequently uploaded and appeared in the user avatar directory).

I rewrote the logic of the loop just a little bit, so that $avatar_url would be preferentially set by a file named by the new avatar filename convention, and only failing that would it look for a legacy name. I replaced

if ( preg_match( "/{$avatar_name}/", $avatar_file ) || preg_match( "/{$legacy_user_avatar_name}/", $avatar_file ) || preg_match( "/{$legacy_group_avatar_name}/", $avatar_file ) )
$avatar_url = $avatar_folder_url . '/' . $avatar_file;


if ( preg_match( "/{$avatar_name}/", $avatar_file ) ) {
$avatar_url = $avatar_folder_url . '/' . $avatar_file;
} else if ( preg_match( "/{$legacy_user_avatar_name}/", $avatar_file ) || preg_match( "/{$legacy_group_avatar_name}/", $avatar_file ) ) {
$avatar_url = $avatar_folder_url . '/' . $avatar_file;

After the change, I (one of the affected users) was able to upload a new avatar and have it stick, and group avatars appear to be functioning normally as well.

Not sure if this is a core bug or not. Maybe someone out there is smarter than me and can chime in?

Skip to toolbar