Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/11/2021 01:40:24 PM (2 years ago)
Author:
imath
Message:

Make sure the new_avatar activity can use the avatar crop results

Since [13175] the BP_Attachment_Avatar::crop() method include the timestamp the avatar was generated on into its returned array. This array is now transported into the action the function creating a new_avatar activity hooks to. This function (bp_members_new_avatar_activity()) now accepts 3 more parameters included the transported crop results. This makes it possible to use the timestamp when the avatar was generated on as the new_avatar activity recorded time. Doing so, we don't need to add an extra activity meta to store the name of the avatar file to be sure to display the avatar the user had at the time the activity was created.

Props vapvarun, oztaser

See #8581

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/screens/change-avatar.php

    r12557 r13177  
    6262        );
    6363
    64         if ( ! bp_core_avatar_handle_crop( $args ) ) {
     64        // Handle crop.
     65        $cropped_avatar = bp_core_avatar_handle_crop( $r, 'array' );
     66
     67        if ( ! $cropped_avatar ) {
    6568            bp_core_add_message( __( 'There was a problem cropping your profile photo.', 'buddypress' ), 'error' );
    6669        } else {
     
    7376             *
    7477             * @since 6.0.0
     78             * @since 10.0.0 Adds a new param: an array containing the full, thumb avatar and the timestamp.
    7579             *
    76              * @param string $item_id Inform about the user id the avatar was set for.
    77              * @param string $value   Inform about the way the avatar was set ('crop').
     80             * @param string $item_id        Inform about the user id the avatar was set for.
     81             * @param string $type           Inform about the way the avatar was set ('camera').
     82             * @param array  $args           Array of parameters passed to the crop handler.
     83             * @param array  $cropped_avatar Array containing the full, thumb avatar and the timestamp.
    7884             */
    79             do_action( 'bp_members_avatar_uploaded', (int) $args['item_id'], 'crop' );
     85            do_action( 'bp_members_avatar_uploaded', (int) $args['item_id'], 'crop', $args, $cropped_avatar );
    8086
    8187            bp_core_add_message( __( 'Your new profile photo was uploaded successfully.', 'buddypress' ) );
Note: See TracChangeset for help on using the changeset viewer.