bp_core_avatar_default

Get the URL of the 'full' default avatar.

Description

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

Returns (string)

The URL of the default avatar.

Parameters (2)

0. $type — Optional. (string) => 'gravatar'
'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 .
1. $params — Optional. (array) => array()
Parameters passed to bp_core_fetch_avatar().

Usage

  1. if ( !function_exists( 'bp_core_avatar_default' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-avatars.php'; 
  3. $type = 'gravatar'; 
  4.  
  5. // Parameters passed to bp_core_fetch_avatar(). 
  6. $params = array(); 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = bp_core_avatar_default($type, $params); 
  10.  

Defined (1)

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

/bp-core/bp-core-avatars.php  
  1. function bp_core_avatar_default( $type = 'gravatar', $params = array() ) { 
  2. // Local override. 
  3. if ( defined( 'BP_AVATAR_DEFAULT' ) ) { 
  4. $avatar = BP_AVATAR_DEFAULT; 
  5.  
  6. // Use the local default image. 
  7. } elseif ( 'local' === $type ) { 
  8. $size = ''; 
  9. if ( 
  10. ( isset( $params['type'] ) && 'thumb' === $params['type'] && bp_core_avatar_thumb_width() <= 50 ) || 
  11. ( isset( $params['width'] ) && $params['width'] <= 50 ) 
  12. ) { 
  13.  
  14. $size = '-50'; 
  15.  
  16. $avatar =buddypress)->plugin_url . "bp-core/images/mystery-man{$size}.jpg"; 
  17.  
  18. // Use Gravatar's mystery person as fallback. 
  19. } else { 
  20. $size = ''; 
  21. if ( isset( $params['type'] ) && 'thumb' === $params['type'] ) { 
  22. } else { 
  23. $avatar = '//www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&s=' . $size; 
  24.  
  25. /** 
  26. * Filters the URL of the 'full' default avatar. 
  27. * @since 1.5.0 
  28. * @since 2.6.0 Added `$params`. 
  29. * @param string $avatar URL of the default avatar. 
  30. * @param array $params Params provided to bp_core_fetch_avatar(). 
  31. */ 
  32. return apply_filters( 'bp_core_avatar_default', $avatar, $params );