[buddypress-trac] [BuddyPress] #2206: strange avatars break uploads

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Sun Apr 25 03:01:33 UTC 2010


#2206: strange avatars break uploads
---------------------+------------------------------------------------------
 Reporter:  luccame  |       Owner:               
     Type:  defect   |      Status:  new          
 Priority:  trivial  |   Milestone:               
Component:  Core     |    Keywords:  avatar upload
---------------------+------------------------------------------------------

Comment(by ipstenu):

 From [http://buddypress.org/community/groups/how-to-and-
 troubleshooting/forum/topic/avatar-upload-issue-1/#post-50231 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

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


More information about the buddypress-trac mailing list