[buddypress-trac] [BuddyPress Trac] #5335: Problem with Retrieving avatar's

buddypress-trac noreply at wordpress.org
Mon Jan 13 21:55:18 UTC 2014


#5335: Problem with Retrieving avatar's
--------------------------+------------------------------
 Reporter:  vusisindane   |       Owner:
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Core          |     Version:  1.9.1
 Severity:  normal        |  Resolution:  fixed
 Keywords:                |
--------------------------+------------------------------
Changes (by vusisindane):

 * status:  new => closed
 * resolution:   => fixed


Comment:

 Here's a temporary fix I've come up with.
 Enjoy
 {{{
 function fix_crop_avatar(){
         global $bp;


         $dir =  bp_core_get_upload_dir() . "/avatars/" .
 bp_loggedin_user_id();

         $full_w = bp_core_avatar_full_width();
         $full_h = bp_core_avatar_full_height();

         $thumb_w = bp_core_avatar_thumb_width();
         $thumb_h = bp_core_avatar_thumb_height();



         if(file_exists($dir)){


                 // open the directory
                 if( $av_dir = opendir($dir)) {

                         $avatar_files = array();

                         while(false !== ($avatar_file =
 readdir($av_dir))){
                                 if( 2 < strlen($avatar_file)){
                                         $avatar_files[] = $avatar_file;
                                 }
                         }

                         $dir = trailingslashit($dir);

                         if( count($avatar_files) > 0){
                                 foreach($avatar_files as $key => $value){

                                         // rename thename of the image
 depending on the size
                                         // first collect some data
                                         if(strpos($value, "-bpfull") ===
 false && strpos($value, "-bpthumb") === false){
                                                 $imgdata =
 @getimagesize($dir . $value);
                                                 $ext = ($imgdata["mime"]
 == "image/png") ? "png" : "jpg";
                                                 $split_file = explode(".",
 $value);

                                                 // this is a thumbnail
                                                 if($imgdata[0] ==
 $thumb_w){
                                                         $newfname =
 $split_file[0] . "-bpthumb." . $split_file[1];
                                                         rename($dir .
 $value, $dir . $newfname);
                                                 }
                                                 else{
                                                         $newfname =
 $split_file[0] . "-bpfull." . $split_file[1];
                                                         rename($dir .
 $value, $dir . $newfname);
                                                 }
                                         }
                                 }
                         }
                 }
         }
 }
 add_action( 'xprofile_avatar_uploaded', "fix_crop_avatar" );
 }}}

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5335#comment:1>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list