Skip to:
Content

BuddyPress.org

Opened 12 years ago

Closed 12 years ago

#1717 closed defect (bug) (no action required)

Use BP constants for xprofile_avatar_upload_dir

Reported by: lunabyte Owned by:
Milestone: 1.2 Priority: major
Severity: Version:
Component: Keywords: avatar, avatar path
Cc:

Description

bp-xprofile.php: function xprofile_avatar_upload_dir();

$path is set with the constant BP_AVATAR_UPLOAD_PATH.

$newurl then replaces WP_CONTENT_DIR with WP_CONTENT_URL.

If BP_AVATAR_UPLOAD_PATH is not in the same path as WP_CONTENT_DIR, it throws avatars into chaos for everything from upload to display, and in between.

Suggest $newurl be changed to honor BP defined constants as follows:

$newurl = str_replace( BP_AVATAR_UPLOAD_PATH, BP_AVATAR_URL, $path );

Thus bringing the function inline with using the same set of constants.

Change History (3)

#1 @lunabyte
12 years ago

Update to add:

bp-core-avatars.php, bp_core_avatar_handle_upload();

$bp->avatar_admin->image->url should also be updated to use BP_AVATAR_UPLOAD_PATH. As a note it already uses BP_AVATAR_URL.

Also, in bp_core_avatar_handle_crop();

Checking for the file (!file_exists) doesn't appear to need anything other than $original_file, as it's passing the entire path.

$avatar_folder_dir right below that should be setup to use BP_AVATAR_UPLOAD_PATH.

I'm sure there will be a few more places. I'll add them as I find them.

#2 @lunabyte
12 years ago

Found what I hope is the final break in the string.

bp-core-avatars.php, bp_core_avatar_handle_crop();

Removing WP_CONTENT_DIR from both full_cropped and thumb_cropped calls to wp_crop_image, and leaving as just original_file, as well as from the @unlink below that, did the trick.

Dunno about blog/group avatars yet.

#3 @apeatling
12 years ago

  • Resolution set to invalid
  • Status changed from new to closed

I've just made all the changes you mentioned and it broke everything. I'm happy to look at a patch, but it needs to work on both MU and single WP.

Note: See TracTickets for help on using tickets.