bp_get_member_avatar( array|string $args = '' )

Get a member’s avatar.

Description

See also

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: 'Profile picture of [user name]'.
  • 'class'
    (string) Default: 'avatar'.
  • 'type'
    (string) Default: 'thumb'.
  • 'width'
    (int|bool) Default: false.
  • 'height'
    (int|bool) Default: false.
  • 'id'
    (bool) Currently unused.
  • 'no_grav'
    (bool) Default: false.

Default value: ''

Return

(string) User avatar string.

Source

File: bp-members/bp-members-template.php

813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
function bp_get_member_avatar( $args = '' ) {
    global $members_template;
 
    $fullname = !empty( $members_template->member->fullname ) ? $members_template->member->fullname : $members_template->member->display_name;
 
    $defaults = array(
        'type'   => 'thumb',
        'width'  => false,
        'height' => false,
        'class'  => 'avatar',
        'id'     => false,
        'alt'    => sprintf( __( 'Profile photo of %s', 'buddyboss' ), $fullname )
    );
 
    $r = wp_parse_args( $args, $defaults );
    extract( $r, EXTR_SKIP );
 
    /**
     * Filters a members avatar.
     *
     * @since BuddyPress 1.2.0
     * @since BuddyPress 2.6.0 Added the `$r` parameter.
     *
     * @param string $value Formatted HTML <img> element, or raw avatar URL based on $html arg.
     * @param array  $r     Array of parsed arguments. See {@link bp_get_member_avatar()}.
     */
    return apply_filters( 'bp_get_member_avatar', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->id, 'type' => $type, 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height, 'email' => $members_template->member->user_email ) ), $r );
}

Changelog

Changelog
Version Description
BuddyPress 1.2.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.