Skip to:
Content

BuddyPress.org

Ticket #8598: 8598.patch

File 8598.patch, 2.7 KB (added by imath, 3 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 f6a69205f..301c6bfdc 100644
    function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) { 
    981981        }
    982982
    983983        // Maybe resize.
     984        $original_file_size        = $avatar_attachment->get_image_data( $bp->avatar_admin->original['file'] );
    984985        $bp->avatar_admin->resized = $avatar_attachment->shrink( $bp->avatar_admin->original['file'], $ui_available_width );
    985986        $bp->avatar_admin->image   = new stdClass();
    986987
    function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) { 
    10031004
    10041005        // If the uploaded image is smaller than the "full" dimensions, throw a warning.
    10051006        if ( $avatar_attachment->is_too_small( $bp->avatar_admin->image->file ) ) {
    1006                 /* translators: 1: the advised width size in pixels. 2: the advised height size in pixels. */
    1007                 bp_core_add_message( sprintf( __( 'You have selected an image that is smaller than recommended. For best results, upload a picture larger than %1$d x %2$d pixels.', 'buddypress' ), bp_core_avatar_full_width(), bp_core_avatar_full_height() ), 'error' );
     1007                if ( isset( $original_file_size['width'] ) && $original_file_size['width'] > bp_core_avatar_full_width() ) {
     1008                        $aspect_ratio = number_format_i18n( bp_core_avatar_full_width() / bp_core_avatar_full_height(), 2 );
     1009
     1010                        /* translators: %s: the value of the aspect ratio. */
     1011                        bp_core_add_message( sprintf( __( 'The aspect ratio of the image you selected is too great compared to the profile photo one. For best results, upload a picture having an aspect ratio closer to %s.', 'buddypress' ), $aspect_ratio ), 'error' );
     1012                } else {
     1013
     1014                        /* translators: 1: the advised width size in pixels. 2: the advised height size in pixels. */
     1015                        bp_core_add_message( sprintf( __( 'You have selected an image that is smaller than recommended. For best results, upload a picture larger than %1$d x %2$d pixels.', 'buddypress' ), bp_core_avatar_full_width(), bp_core_avatar_full_height() ), 'error' );
     1016                }
    10081017        }
    10091018
    10101019        // Set the url value for the image.
  • src/bp-core/js/bp-plupload.js

    diff --git src/bp-core/js/bp-plupload.js src/bp-core/js/bp-plupload.js
    index d73bd8931..3416de196 100644
    window.bp = window.bp || {}; 
    8080                         * checked during the upload process to eventually adapt the resized avatar.
    8181                         */
    8282                        if ( 'bp_avatar_upload' ===  uploader.settings.multipart_params.action ) {
    83                                  uploader.settings.multipart_params.bp_params.ui_available_width = container.width();
     83                                uploader.settings.multipart_params.bp_params.ui_available_width = container.width();
    8484                        }
    8585
    8686                        if ( uploader.features.dragdrop && ! self.params.browser.mobile ) {