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-groups/actions/create.php

    r12433 r13177  
    271271            );
    272272
    273             if ( ! bp_core_avatar_handle_crop( $args ) ) {
     273            $cropped_avatar = bp_core_avatar_handle_crop( $args, 'array' );
     274
     275            if ( ! $cropped_avatar ) {
    274276                bp_core_add_message( __( 'There was an error saving the group profile photo, please try uploading again.', 'buddypress' ), 'error' );
    275277            } else {
     
    278280                 *
    279281                 * @since 2.8.0
     282                 * @since 10.0.0 Adds a new param: an array containing the full, thumb avatar and the timestamp.
    280283                 *
    281                  * @param int    $group_id ID of the group.
    282                  * @param string $type     Avatar type. 'crop' or 'full'.
    283                  * @param array  $args     Array of parameters passed to the avatar handler.
     284                 * @param int    $group_id       ID of the group.
     285                 * @param string $type           Avatar type. 'crop' or 'camera'.
     286                 * @param array  $args           Array of parameters passed to the crop handler.
     287                 * @param array  $cropped_avatar Array containing the full, thumb avatar and the timestamp.
    284288                 */
    285                 do_action( 'groups_avatar_uploaded', bp_get_current_group_id(), 'crop', $args );
     289                do_action( 'groups_avatar_uploaded', bp_get_current_group_id(), 'crop', $args, $cropped_avatar );
    286290
    287291                bp_core_add_message( __( 'The group profile photo was uploaded successfully.', 'buddypress' ) );
Note: See TracChangeset for help on using the changeset viewer.