Skip to:
Content

BuddyPress.org

Ticket #2317: avatar-path-and-url-fix-jjj.patch

File avatar-path-and-url-fix-jjj.patch, 5.3 KB (added by johnjamesjacoby, 10 years ago)

needs-testing

  • bp-core/bp-core-avatars.php

     
    108108        else
    109109                $html_height = ( 'thumb' == $type ) ? ' height="' . BP_AVATAR_THUMB_HEIGHT . '"' : ' height="' . BP_AVATAR_FULL_HEIGHT . '"';
    110110
    111         $avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', str_replace( WP_CONTENT_DIR, BP_AVATAR_URL, BP_AVATAR_UPLOAD_PATH ) . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
     111        $avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', BP_AVATAR_URL . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
    112112        $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', BP_AVATAR_UPLOAD_PATH . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
    113113
    114114        /****
     
    300300        }
    301301
    302302        /* Set the url value for the image */
    303         $bp->avatar_admin->image->url = str_replace( WP_CONTENT_DIR, BP_AVATAR_URL, $bp->avatar_admin->image->dir );
     303        $bp->avatar_admin->image->url = str_replace( BP_AVATAR_UPLOAD_PATH, BP_AVATAR_URL, $bp->avatar_admin->image->dir );
    304304
    305305        return true;
    306306}
     
    333333        if ( !$original_file )
    334334                return false;
    335335
    336         if ( !file_exists( WP_CONTENT_DIR . '/' . $original_file ) )
     336        if ( is_multisite () )
     337                $original_file = WP_CONTENT_DIR . str_replace( BP_AVATAR_URL, BP_AVATAR_UPLOAD_PATH, $original_file );
     338        else
     339                $original_file = str_replace( BP_AVATAR_URL, BP_AVATAR_UPLOAD_PATH, $original_file );
     340
     341        if ( !file_exists( $original_file ) )
    337342                return false;
    338343
    339344        if ( !$item_id )
    340                 $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . dirname( $original_file ), $item_id, $object, $avatar_dir );
     345                $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', BP_AVATAR_UPLOAD_PATH . dirname( $original_file ), $item_id, $object, $avatar_dir );
    341346        else
    342347                $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', BP_AVATAR_UPLOAD_PATH . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
    343348
     
    362367        $thumb_filename = wp_hash( $original_file . time() ) . '-bpthumb.jpg';
    363368
    364369        /* Crop the image */
    365         $full_cropped = wp_crop_image( WP_CONTENT_DIR . $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_FULL_WIDTH, BP_AVATAR_FULL_HEIGHT, false, $avatar_folder_dir . '/' . $full_filename );
    366         $thumb_cropped = wp_crop_image( WP_CONTENT_DIR . $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_THUMB_WIDTH, BP_AVATAR_THUMB_HEIGHT, false, $avatar_folder_dir . '/' . $thumb_filename );
     370        $full_cropped = wp_crop_image( $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_FULL_WIDTH, BP_AVATAR_FULL_HEIGHT, false, $avatar_folder_dir . '/' . $full_filename );
     371        $thumb_cropped = wp_crop_image( $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_THUMB_WIDTH, BP_AVATAR_THUMB_HEIGHT, false, $avatar_folder_dir . '/' . $thumb_filename );
    367372
    368373        /* Remove the original */
    369         @unlink( WP_CONTENT_DIR . $original_file );
     374        @unlink( $original_file );
    370375
    371376        return true;
    372377}
     
    413418}
    414419
    415420function bp_core_avatar_upload_path() {
    416         if ( bp_core_is_multisite() )
    417                 $path = ABSPATH . get_blog_option( BP_ROOT_BLOG, 'upload_path' );
    418         else {
    419                 if ( !$path = get_option( 'upload_path' ) )
    420                         $path = WP_CONTENT_DIR . '/uploads';
    421                 else
    422                         $path = ABSPATH . $path;
    423         }
    424 
    425         return apply_filters( 'bp_core_avatar_upload_path', $path );
     421        $upload_dir = wp_upload_dir();
     422        return apply_filters( 'bp_core_avatar_upload_path', $upload_dir['basedir'] );
    426423}
    427424
    428425function bp_core_avatar_url() {
    429         if ( !bp_core_is_multisite() )
    430                 return WP_CONTENT_URL;
    431 
    432         return apply_filters( 'bp_core_avatar_url', get_blog_option( BP_ROOT_BLOG, 'siteurl' ) );
     426        $upload_dir = wp_upload_dir();
     427        return apply_filters( 'bp_core_avatar_url', $upload_dir['baseurl'] );
    433428}
    434429
    435430?>
     431 No newline at end of file
  • bp-core/bp-core-signup.php

     
    519519        if ( !file_exists( $path ) )
    520520                @wp_mkdir_p( $path );
    521521
    522         $newurl = str_replace( BP_AVATAR_UPLOAD_PATH, BP_AVATAR_URL, $path );
     522        $newurl = BP_AVATAR_URL . '/avatars/signups/' . $bp->signup->avatar_dir;
    523523        $newburl = $newurl;
    524524        $newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir;
    525525
  • bp-groups.php

     
    18601860        if ( !file_exists( $path ) )
    18611861                @wp_mkdir_p( $path );
    18621862
    1863         $newurl = str_replace( BP_AVATAR_UPLOAD_PATH, BP_AVATAR_URL, $path );
     1863        $newurl = BP_AVATAR_URL . '/group-avatars/' . $group_id;
    18641864        $newburl = $newurl;
    18651865        $newsubdir = '/group-avatars/' . $group_id;
    18661866
  • bp-xprofile.php

     
    879879        if ( !file_exists( $path ) )
    880880                @wp_mkdir_p( $path );
    881881
    882         $newurl = str_replace( BP_AVATAR_UPLOAD_PATH, BP_AVATAR_URL, $path );
     882        $newurl  = BP_AVATAR_URL . '/avatars/' . $user_id;
    883883        $newburl = $newurl;
    884884        $newsubdir = '/avatars/' . $user_id;
    885885