Skip to:
Content

BuddyPress.org

Ticket #5617: 5617.patch

File 5617.patch, 2.6 KB (added by boonebgorges, 11 years ago)
  • src/bp-core/bp-core-avatars.php

    diff --git src/bp-core/bp-core-avatars.php src/bp-core/bp-core-avatars.php
    index 93e7781..7fc7000 100644
    function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) { 
    670670                return false;
    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 ( $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 %s x %s 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;
    675684
  • src/bp-core/bp-core-cssjs.php

    diff --git src/bp-core/bp-core-cssjs.php src/bp-core/bp-core-cssjs.php
    index 7a816a7..1938590 100644
    function bp_core_add_cropper_inline_js() { 
    6060        }
    6161
    6262        // Default cropper coordinates
    63         $crop_left   = round( $image[0] / 4 );
    64         $crop_top    = round( $image[1] / 4 );
    65         $crop_right  = $image[0] - $crop_left;
    66         $crop_bottom = $image[1] - $crop_top; ?>
     63
     64        // Smaller than full-width: cropper defaults to entire image
     65        if ( $image[0] < $full_width ) {
     66                $crop_left  = 0;
     67                $crop_right = $image[0];
     68
     69        // Less than 2x full-width: cropper defaults to full-width
     70        } else if ( $image[0] < ( $full_width * 2 ) ) {
     71                $padding_w  = round( ( $image[0] - $full_width ) / 2 );
     72                $crop_left  = $padding_w;
     73                $crop_right = $image[0] - $padding_w;
     74
     75        // Larger than 2x full-width: cropper defaults to 1/2 image width
     76        } else {
     77                $crop_left  = round( $image[0] / 4 );
     78                $crop_right = $image[0] - $crop_left;
     79        }
     80
     81        // Smaller than full-height: cropper defaults to entire image
     82        if ( $image[1] < $full_height ) {
     83                $crop_top    = 0;
     84                $crop_bottom = $image[1];
     85
     86        // Less than double full-height: cropper defaults to full-height
     87        } else if ( $image[1] < ( $full_height * 2 ) ) {
     88                $padding_h   = round( ( $image[1] - $full_height ) / 2 );
     89                $crop_top    = $padding_h;
     90                $crop_bottom = $image[1] - $padding_h;
     91
     92        // Larger than 2x full-height: cropper defaults to 1/2 image height
     93        } else {
     94                $crop_top    = round( $image[1] / 4 );
     95                $crop_bottom = $image[1] - $crop_top;
     96        }
     97
     98        ?>
    6799
    68100        <script type="text/javascript">
    69101                jQuery(window).load( function(){