bp_activity_comments_user_avatars( array $args = array() )
Echo a list of linked avatars of users who have commented on the current activity item.
Description
Use this function to easily output activity comment authors’ avatars.
Avatars are wrapped in
- or
- bp_core_fetch_avatar(): for a description of arguments.
- wrapper markup.
See also
Parameters
- $args
-
(Optional) See bp_core_fetch_avatar().
Default value: array()
Source
File: bp-activity/bp-activity-template.php
3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 | function bp_activity_comments_user_avatars( $args = array () ) { $r = bp_parse_args( $args , array ( 'height' => false, 'html' => true, 'type' => 'thumb' , 'width' => false, ) ); // Get the user IDs of everyone who has left a comment to the current activity item. $user_ids = bp_activity_get_comments_user_ids(); $output = array (); $retval = '' ; if ( ! empty ( $user_ids ) ) { foreach ( ( array ) $user_ids as $user_id ) { // Skip an empty user ID. if ( empty ( $user_id ) ) { continue ; } // Get profile link for this user. $profile_link = bp_core_get_user_domain( $user_id ); // Get avatar for this user. $image_html = bp_core_fetch_avatar( array ( 'item_id' => $user_id , 'height' => $r [ 'height' ], 'html' => $r [ 'html' ], 'type' => $r [ 'type' ], 'width' => $r [ 'width' ] ) ); // If user has link & avatar, add them to the output array. if ( ! empty ( $profile_link ) && ! empty ( $image_html ) ) { $output [] = sprintf( '<a href="%1$s">%2$s</a>' , esc_url( $profile_link ), $image_html ); } } // If output array is not empty, wrap everything in some list items. if ( ! empty ( $output ) ) { $retval = '<li>' . implode( '</li><li>' , $output ) . '</li>' ; } } /** * Filters the list of linked avatars for users who have commented on the current activity item. * * @since BuddyPress 1.7.0 * * @param string $retval HTML markup for the list of avatars. * @param array $r Array of arguments used for each avatar. * @param array $output Array of each avatar found, before imploded into single string. */ echo apply_filters( 'bp_activity_comments_user_avatars' , $retval , $r , $output ); } |
Changelog
Version | Description |
---|---|
BuddyPress 1.7.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.