Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/28/2010 05:44:28 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Fixes #2206 props ipstenu

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.2/bp-core/bp-core-avatars.php

    r2943 r2957  
    275275    }
    276276
    277     /* Resize the image down to something manageable and then delete the original */
    278     if ( getimagesize( $bp->avatar_admin->original['file'] ) > BP_AVATAR_ORIGINAL_MAX_WIDTH )
    279         $bp->avatar_admin->resized = wp_create_thumbnail( $bp->avatar_admin->original['file'], BP_AVATAR_ORIGINAL_MAX_WIDTH );
    280 
    281     $bp->avatar_admin->image = new stdClass;
     277    /* Get image size */
     278    $size = @getimagesize( $bp->avatar_admin->original['file'] );
     279
     280    /* Check image size and shrink if too large */
     281    if ( $size[0] > BP_AVATAR_ORIGINAL_MAX_WIDTH ) {
     282        $thumb = wp_create_thumbnail( $bp->avatar_admin->original['file'], BP_AVATAR_ORIGINAL_MAX_WIDTH );
     283
     284        /* Check for thumbnail creation errors */
     285        if ( is_wp_error( $thumb ) ) {
     286            bp_core_add_message( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $thumb->get_error_message() ), 'error' );
     287            return false;
     288        }
     289
     290        /* Thumbnail is good so proceed */
     291        $bp->avatar_admin->resized = $thumb;
     292    }
    282293
    283294    /* We only want to handle one image after resize. */
Note: See TracChangeset for help on using the changeset viewer.