bp_get_group_avatar( array|string $args = '' )
Get a group’s avatar.
Description
See also
- bp_core_fetch_avatar(): For a description of arguments and return values.
Parameters
- $args
-
(Optional) Arguments are listed here with an explanation of their defaults. For more information about the arguments, see bp_core_fetch_avatar().
- 'alt'
(string) Default: 'Group logo of [group name]'. - 'class'
(string) Default: 'avatar'. - 'type'
(string) Default: 'full'. - 'width'
(int|bool) Default: false. - 'height'
(int|bool) Default: false. - 'id'
(bool) Passed to$css_id
parameter.
Default value: ''
- 'alt'
Return
(string) Group avatar string.
Source
File: bp-groups/bp-groups-template.php
function bp_get_group_avatar( $args = '' ) { global $groups_template; // Bail if avatars are turned off. if ( bp_disable_group_avatar_uploads() || ! buddypress()->avatar->show_avatars ) { return false; } // Parse the arguments. $r = bp_parse_args( $args, array( 'type' => 'full', 'width' => false, 'height' => false, 'class' => 'avatar', 'id' => false, 'alt' => sprintf( __( 'Group logo of %s', 'buddyboss' ), $groups_template->group->name ) ) ); // Fetch the avatar from the folder. $avatar = bp_core_fetch_avatar( array( 'item_id' => $groups_template->group->id, 'avatar_dir' => 'group-avatars', 'object' => 'group', 'type' => $r['type'], 'alt' => $r['alt'], 'css_id' => $r['id'], 'class' => $r['class'], 'width' => $r['width'], 'height' => $r['height'], ) ); // If No avatar found, provide some backwards compatibility. if ( empty( $avatar ) ) { $avatar = '<img src="' . esc_url( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . esc_attr( $groups_template->group->name ) . '" />'; } /** * Filters the group avatar while in the groups loop. * * @since BuddyPress 1.0.0 * * @param string $avatar HTML image element holding the group avatar. * @param array $r Array of parsed arguments for the group avatar. */ return apply_filters( 'bp_get_group_avatar', $avatar, $r ); }
Changelog
Version | Description |
---|---|
BuddyPress 1.0.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.