bp_get_activity_avatar

Return the avatar of the user that performed the action.

Description

(string) bp_get_activity_avatar( (string) $args = '' ); 

Returns (string)

User avatar string.

Parameters (1)

0. $args — Optional. (string) => ''
The args.

Options

    ;        


    Usage

    1. if ( !function_exists( 'bp_get_activity_avatar' ) ) { 
    2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-template.php'; 
    3.  
    4. // The args. 
    5. $args = ''; 
    6.  
    7. // NOTICE! Understand what this does before running. 
    8. $result = bp_get_activity_avatar($args); 
    9.  

    Defined (1)

    The function is defined in the following location(s).

    /bp-activity/bp-activity-template.php  
    1. function bp_get_activity_avatar( $args = '' ) { 
    2. global $activities_template; 
    3.  
    4. $bp =buddypress); 
    5.  
    6. // On activity permalink pages, default to the full-size avatar. 
    7. $type_default = bp_is_single_activity() ? 'full' : 'thumb'; 
    8.  
    9. // Within the activity comment loop, the current activity should be set 
    10. // to current_comment. Otherwise, just use activity. 
    11. $current_activity_item = isset( $activities_template->activity->current_comment ) ? $activities_template->activity->current_comment : $activities_template->activity; 
    12.  
    13. // Activity user display name. 
    14. $dn_default = isset( $current_activity_item->display_name ) ? $current_activity_item->display_name : ''; 
    15.  
    16. // Prepend some descriptive text to alt. 
    17. $alt_default = !empty( $dn_default ) ? sprintf( __( 'Profile picture of %s', buddypress ), $dn_default ) : __( 'Profile picture', buddypress ); 
    18.  
    19. $defaults = array( 
    20. 'alt' => $alt_default,  
    21. 'class' => 'avatar',  
    22. 'email' => false,  
    23. 'type' => $type_default,  
    24. 'user_id' => false 
    25. ); 
    26.  
    27. $r = wp_parse_args( $args, $defaults ); 
    28. extract( $r, EXTR_SKIP ); 
    29.  
    30. if ( !isset( $height ) && !isset( $width ) ) { 
    31.  
    32. // Backpat. 
    33. if ( isset( $bp->avatar->full->height ) || isset( $bp->avatar->thumb->height ) ) { 
    34. $height = ( 'full' == $type ) ? $bp->avatar->full->height : $bp->avatar->thumb->height; 
    35. } else { 
    36. $height = 20; 
    37.  
    38. // Backpat. 
    39. if ( isset( $bp->avatar->full->width ) || isset( $bp->avatar->thumb->width ) ) { 
    40. $width = ( 'full' == $type ) ? $bp->avatar->full->width : $bp->avatar->thumb->width; 
    41. } else { 
    42. $width = 20; 
    43.  
    44. /** 
    45. * Filters the activity avatar object based on current activity item component. 
    46. * This is a variable filter dependent on the component used. 
    47. * Possible hooks are bp_get_activity_avatar_object_blog,  
    48. * bp_get_activity_avatar_object_group, and bp_get_activity_avatar_object_user. 
    49. * @since 1.1.0 
    50. * @param string $component Component being displayed. 
    51. */ 
    52. $object = apply_filters( 'bp_get_activity_avatar_object_' . $current_activity_item->component, 'user' ); 
    53. $item_id = !empty( $user_id ) ? $user_id : $current_activity_item->user_id; 
    54.  
    55. /** 
    56. * Filters the activity avatar item ID. 
    57. * @since 1.2.10 
    58. * @param int $item_id Item ID for the activity avatar. 
    59. */ 
    60.  
    61. // If this is a user object pass the users' email address for Gravatar so we don't have to prefetch it. 
    62. if ( 'user' == $object && empty( $user_id ) && empty( $email ) && isset( $current_activity_item->user_email ) ) { 
    63. $email = $current_activity_item->user_email; 
    64.  
    65. /** 
    66. * Filters the value returned by bp_core_fetch_avatar. 
    67. * @since 1.1.3 
    68. * @param array $value HTML image element containing the activity avatar. 
    69. */ 
    70. 'item_id' => $item_id,  
    71. 'object' => $object,  
    72. 'type' => $type,  
    73. 'alt' => $alt,  
    74. 'class' => $class,  
    75. 'width' => $width,  
    76. 'height' => $height,  
    77. 'email' => $email 
    78. ) ) );