bp_get_activity_secondary_avatar

Return the avatar of the object that action was performed on.

Description

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

Returns (string)

The secondary avatar.

Parameters (1)

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

Options

    ;        


    Usage

    1. if ( !function_exists( 'bp_get_activity_secondary_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_secondary_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_secondary_avatar( $args = '' ) { 
    2. global $activities_template; 
    3.  
    4. $r = wp_parse_args( $args, array( 
    5. 'alt' => '',  
    6. 'type' => 'thumb',  
    7. 'width' => 20,  
    8. 'height' => 20,  
    9. 'class' => 'avatar',  
    10. 'link_class' => '',  
    11. 'linked' => true,  
    12. 'email' => false 
    13. ) ); 
    14. extract( $r, EXTR_SKIP ); 
    15.  
    16. // Set item_id and object (default to user). 
    17. switch ( $activities_template->activity->component ) { 
    18. case 'groups' : 
    19. return false; 
    20.  
    21. $object = 'group'; 
    22. $item_id = $activities_template->activity->item_id; 
    23. $link = ''; 
    24. $name = ''; 
    25.  
    26. // Only if groups is active. 
    27. if ( bp_is_active( 'groups' ) ) { 
    28. $group = groups_get_group( $item_id ); 
    29. $link = bp_get_group_permalink( $group ); 
    30. $name = $group->name; 
    31.  
    32. if ( empty( $alt ) ) { 
    33. $alt = __( 'Group logo', buddypress ); 
    34.  
    35. if ( ! empty( $name ) ) { 
    36. $alt = sprintf( __( 'Group logo of %s', buddypress ), $name ); 
    37.  
    38. break; 
    39. case 'blogs' : 
    40. $object = 'blog'; 
    41. $item_id = $activities_template->activity->item_id; 
    42. $link = home_url(); 
    43.  
    44. if ( empty( $alt ) ) { 
    45. $alt = sprintf( __( 'Profile picture of the author of the site %s', buddypress ), get_blog_option( $item_id, 'blogname' ) ); 
    46.  
    47. break; 
    48. case 'friends' : 
    49. $object = 'user'; 
    50. $item_id = $activities_template->activity->secondary_item_id; 
    51. $link = bp_core_get_userlink( $item_id, false, true ); 
    52.  
    53. if ( empty( $alt ) ) { 
    54. $alt = sprintf( __( 'Profile picture of %s', buddypress ), bp_core_get_user_displayname( $activities_template->activity->secondary_item_id ) ); 
    55.  
    56. break; 
    57. default : 
    58. $object = 'user'; 
    59. $item_id = $activities_template->activity->user_id; 
    60. $email = $activities_template->activity->user_email; 
    61. $link = bp_core_get_userlink( $item_id, false, true ); 
    62.  
    63. if ( empty( $alt ) ) { 
    64. $alt = sprintf( __( 'Profile picture of %s', buddypress ), $activities_template->activity->display_name ); 
    65.  
    66. break; 
    67.  
    68. /** 
    69. * Filters the activity secondary avatar object based on current activity item component. 
    70. * This is a variable filter dependent on the component used. Possible hooks are 
    71. * bp_get_activity_secondary_avatar_object_blog, bp_get_activity_secondary_avatar_object_group,  
    72. * and bp_get_activity_secondary_avatar_object_user. 
    73. * @since 1.2.10 
    74. * @param string $object Component being displayed. 
    75. */ 
    76. $object = apply_filters( 'bp_get_activity_secondary_avatar_object_' . $activities_template->activity->component, $object ); 
    77.  
    78. /** 
    79. * Filters the activity secondary avatar item ID. 
    80. * @since 1.2.10 
    81. * @param int $item_id ID for the secondary avatar item. 
    82. */ 
    83.  
    84. // If we have no item_id or object, there is no avatar to display. 
    85. if ( empty( $item_id ) || empty( $object ) ) { 
    86. return false; 
    87.  
    88. // Get the avatar. 
    89. $avatar = bp_core_fetch_avatar( array( 
    90. 'item_id' => $item_id,  
    91. 'object' => $object,  
    92. 'type' => $type,  
    93. 'alt' => $alt,  
    94. 'class' => $class,  
    95. 'width' => $width,  
    96. 'height' => $height,  
    97. 'email' => $email 
    98. ) ); 
    99.  
    100. if ( !empty( $linked ) ) { 
    101.  
    102. /** 
    103. * Filters the secondary avatar link for current activity. 
    104. * @since 1.7.0 
    105. * @param string $link Link to wrap the avatar image in. 
    106. * @param string $component Activity component being acted on. 
    107. */ 
    108. $link = apply_filters( 'bp_get_activity_secondary_avatar_link', $link, $activities_template->activity->component ); 
    109.  
    110. /** 
    111. * Filters the determined avatar for the secondary activity item. 
    112. * @since 1.2.10 
    113. * @param string $avatar Formatted HTML <img> element, or raw avatar URL. 
    114. */ 
    115.  
    116. return sprintf( '<a href="%s" class="%s">%s</a>',  
    117. $link,  
    118. $link_class,  
    119. $avatar 
    120. ); 
    121.  
    122. /** This filter is documented in bp-activity/bp-activity-template.php */