Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Avatar Upload Issue


Phlux0r
Participant

@phlux0r

Looks like in BuddyPress 1.2.3 the avatar size check is not compatible with the WordPress thumbnailing function.

If you look in bp-code/bp-core-avatars.php, function: bp_core_avatar_handle_upload()

there is a getimagesize() call. That actually returns an array, not a single value so the if statement will not evaluate correctly and the code will always attempt to create a thumbnail. If that fails, the wp_create_thumbnail() function returns a WP_Error object, hence the message some are getting.

here’s my modded code to fix this issue:

/* Resize the image down to something manageable and then delete the original */
/* HACK made some changes to check image parameters more carefully */
$_size = getimagesize( $bp->avatar_admin->original['file'] );
if ( $_size[0] > BP_AVATAR_ORIGINAL_MAX_WIDTH ) {
$_thumb = wp_create_thumbnail( $bp->avatar_admin->original['file'], BP_AVATAR_ORIGINAL_MAX_WIDTH );
// Need to check if upload succeeded - issue with small files!
if ( is_object($_thumb) && get_class($_thumb) == 'WP_Error' ) {
bp_core_add_message( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $_thumb->get_error_message()), 'error');
return false;
}
$bp->avatar_admin->resized = $_thumb;
}

HTH

Skip to toolbar