bp_core_avatar_default( string $type = 'gravatar', array $params = array() )

Get the URL of the ‘full’ default avatar.


Description Description


Parameters Parameters

$type

(Optional) 'local' if the fallback should be the locally-hosted version of the mystery person, 'gravatar' if the fallback should be Gravatar's version. Default: 'gravatar'.

Default value: 'gravatar'

$params

(Optional) Parameters passed to bp_core_fetch_avatar().

Default value: array()


Top ↑

Return Return

(string) The URL of the default avatar.


Top ↑

Source Source

File: bp-core/bp-core-avatars.php

function bp_core_avatar_default( $type = 'gravatar', $params = array() ) {
	// Local override.
	if ( defined( 'BP_AVATAR_DEFAULT' ) ) {
		$avatar = BP_AVATAR_DEFAULT;

	// Use the local default image.
	} elseif ( 'local' === $type ) {
		$size = '';
		if (
			( isset( $params['type'] ) && 'thumb' === $params['type'] && bp_core_avatar_thumb_width() <= 50 ) ||
			( isset( $params['width'] ) && $params['width'] <= 50 )
		) {

			$size = '-50';
		}

		$avatar = buddypress()->plugin_url . "bp-core/images/mystery-man{$size}.jpg";

	// Use Gravatar's mystery person as fallback.
	} else {
		$size = '';
		if ( isset( $params['type'] ) && 'thumb' === $params['type'] ) {
			$size = bp_core_avatar_thumb_width();
		} else {
			$size = bp_core_avatar_full_width();
		}
		$avatar = '//www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&amp;s=' . $size;
	}

	/**
	 * Filters the URL of the 'full' default avatar.
	 *
	 * @since 1.5.0
	 * @since 2.6.0 Added `$params`.
	 *
	 * @param string $avatar URL of the default avatar.
	 * @param array  $params Params provided to bp_core_fetch_avatar().
	 */
	return apply_filters( 'bp_core_avatar_default', $avatar, $params );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 Introduced $params and $object_type parameters.
1.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.