[buddypress-trac] [BuddyPress] #4092: Buddypress will show wrong user avatars if they contain -bpfull or -bpthumb anywhere in their filename

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Wed Mar 21 22:10:15 UTC 2012


#4092: Buddypress will show wrong user avatars if they contain -bpfull or -bpthumb
anywhere in their filename
--------------------------+-----------------------------
 Reporter:  defunctlife   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Core          |    Version:  1.5.4
 Severity:  normal        |   Keywords:  needs-patch
--------------------------+-----------------------------
 I think a theme created some avatars in the format of -bpfull-24x24.jpg.
 Not sure yet where they came from, but it does show a bug.

 When Buddypress is checking for user avatars, it will pick whichever was
 last in the array, in my case it happened to be this file rather than the
 expected -bpfull.jpg.

 In bp-core-avatars.php, line 211:


 {{{
                                 // Check for current avatar
                                 foreach( $avatar_files as $key => $value )
 {
                                         if ( strpos ( $value, $avatar_size
 )!== false )
                                                 $avatar_url =
 $avatar_folder_url . '/' . $avatar_files[$key];
                                 }
 }}}

 it just overwrites the $avatar_url variable with as many matches as it
 finds.

 I did a fix, but I'm sure someone has a better way to do it


 {{{
                                 // Check for current avatar
                                 foreach( $avatar_files as $key => $value )
 {
                                         $avatar_length = strlen(
 $avatar_size );
                                         $avatar_file_length = -11;

                                         if( $avatar_size == '-bpthumb')
                                                 $avatar_file_length = -12;

                                         if( substr( $value,
 $avatar_file_length, $avatar_length ) == $avatar_size )
                                                 $avatar_url =
 $avatar_folder_url . '/' . $avatar_files[$key];
                                 }
 }}}

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/4092>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list