Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/07/2015 04:47:14 PM (10 years ago)
Author:
imath
Message:

Avatar UI: make sure to display the full content of the image during the cropping step.

When a user uploads an image to set his avatar, we are saving a temporary version of it resized using the bp_core_avatar_original_max_width() dimension (by default 450px). This resized image will be output to the user so that he can edit it during the cropping step. Once the avatar is saved, we are deleting this temporary image.

Sometimes, the Avatar UI width is smaller than this resized version of the image and as a result the image is truncated on its right side (this mainly happens on mobile devices). To avoid this, the Avatar UI is now informing about its available width and if it is smaller than bp_core_avatar_original_max_width(). This available width will be used to generate the tempory image so that the full content of the image will be displayed to the user when cropping his avatar.

Fixes #6586

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-avatars.php

    r10151 r10206  
    821821    }
    822822
     823    // The Avatar UI available width
     824    $ui_available_width = 0;
     825
     826    // Try to set the ui_available_width using the avatar_admin global
     827    if ( isset( $bp->avatar_admin->ui_available_width ) ) {
     828        $ui_available_width = $bp->avatar_admin->ui_available_width;
     829    }
     830
    823831    // Maybe resize.
    824     $bp->avatar_admin->resized = $avatar_attachment->shrink( $bp->avatar_admin->original['file'] );
     832    $bp->avatar_admin->resized = $avatar_attachment->shrink( $bp->avatar_admin->original['file'], $ui_available_width );
    825833    $bp->avatar_admin->image   = new stdClass();
    826834
     
    932940    if ( ! isset( $bp->avatar_admin ) ) {
    933941        $bp->avatar_admin = new stdClass();
     942    }
     943
     944    /**
     945     * The BuddyPress upload parameters is including the Avatar UI Available width,
     946     * add it to the avatar_admin global for a later use.
     947     */
     948    if ( isset( $bp_params['ui_available_width'] ) ) {
     949        $bp->avatar_admin->ui_available_width =  (int) $bp_params['ui_available_width'];
    934950    }
    935951
Note: See TracChangeset for help on using the changeset viewer.