bp_get_group_avatar

Get a group's avatar.

Description

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

Returns (string)

Group avatar string.

Parameters (1)

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

Options

    ;        


    Usage

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

    Defined (1)

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

    /bp-groups/bp-groups-template.php  
    1. function bp_get_group_avatar( $args = '' ) { 
    2. global $groups_template; 
    3.  
    4. // Bail if avatars are turned off. 
    5. if ( bp_disable_group_avatar_uploads() || !buddypress)->avatar->show_avatars ) { 
    6. return false; 
    7.  
    8. // Parse the arguments. 
    9. $r = bp_parse_args( $args, array( 
    10. 'type' => 'full',  
    11. 'width' => false,  
    12. 'height' => false,  
    13. 'class' => 'avatar',  
    14. 'id' => false,  
    15. 'alt' => sprintf( __( 'Group logo of %s', buddypress ), $groups_template->group->name ) 
    16. ) ); 
    17.  
    18. // Fetch the avatar from the folder. 
    19. $avatar = bp_core_fetch_avatar( array( 
    20. 'item_id' => $groups_template->group->id,  
    21. 'avatar_dir' => 'group-avatars',  
    22. 'object' => 'group',  
    23. 'type' => $r['type'],  
    24. 'alt' => $r['alt'],  
    25. 'css_id' => $r['id'],  
    26. 'class' => $r['class'],  
    27. 'width' => $r['width'],  
    28. 'height' => $r['height'],  
    29. ) ); 
    30.  
    31. // If No avatar found, provide some backwards compatibility. 
    32. if ( empty( $avatar ) ) { 
    33. $avatar = '<img src="' . esc_url( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . esc_attr( $groups_template->group->name ) . '" />'; 
    34.  
    35. /** 
    36. * Filters the group avatar while in the groups loop. 
    37. * @since 1.0.0 
    38. * @param string $avatar HTML image element holding the group avatar. 
    39. * @param array $r Array of parsed arguments for the group avatar. 
    40. */ 
    41. return apply_filters( 'bp_get_group_avatar', $avatar, $r );