Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/23/2014 02:43:05 PM (11 years ago)
Author:
boonebgorges
Message:

Improved image size detection for uploaded avatar images

This changeset introduces two fixes that improve the UX for the avatar upload
process with original images of various sizes:

  • Be sensitive to the size of the original image when setting the initial dimensions of the crop box. If the uploaded image is smaller than the "full" avatar size, suggest a crop that contains the entire image; if slightly larger than the "full" size, suggest a crop equivalent to the "full" size.
  • When a too-small image is uploaded, throw a message that suggests a larger one.

See #5617

File:
1 edited

Legend:

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

    r8542 r8673  
    671671    }
    672672
     673    // If the uploaded image is smaller than the "full" dimensions, throw
     674    // a warning
     675    $uploaded_image = @getimagesize( bp_core_avatar_upload_path() . buddypress()->avatar_admin->image->dir );
     676    $full_width     = bp_core_avatar_full_width();
     677    $full_height    = bp_core_avatar_full_height();
     678    if ( isset( $uploaded_image[0] ) && $uploaded_image[0] < $full_width || $uploaded_image[1] < $full_height ) {
     679        bp_core_add_message( sprintf( __( 'You have selected an image that is smaller than recommended. For best results, upload a picture larger than %d x %d pixels.', 'buddypress' ), $full_width, $full_height ), 'error' );
     680    }
     681
    673682    // Set the url value for the image
    674683    $bp->avatar_admin->image->url = bp_core_avatar_url() . $bp->avatar_admin->image->dir;
Note: See TracChangeset for help on using the changeset viewer.