Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/14/2021 08:39:57 PM (2 years ago)
Author:
imath
Message:

Add a feedback message to the Avatar UI in case of aspect ratio issue

Props niftythree

Fixes #8598

File:
1 edited

Legend:

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

    r13108 r13152  
    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();
     
    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
Note: See TracChangeset for help on using the changeset viewer.