get_avatar
Filters the HTML for a user's avatar.
Usage
add_filter( 'get_avatar', 'wp_kama_get_avatar_filter', 10, 6 );
/**
* Function for `get_avatar` filter-hook.
*
* @param string $avatar HTML for the user's avatar.
* @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash, user email, WP_User object, WP_Post object, or WP_Comment object.
* @param int $size Height and width of the avatar in pixels.
* @param string $default_value URL for the default image or a default type. Accepts:
- '404' (return a 404 instead of a default image)
- 'retro' (a 8-bit arcade-style pixelated face)
- 'robohash' (a robot)
- 'monsterid' (a monster)
- 'wavatar' (a cartoon face)
- 'identicon' (the "quilt", a geometric pattern)
- 'mystery', 'mm', or 'mysteryman' (The Oyster Man)
- 'blank' (transparent GIF)
- 'gravatar_default' (the Gravatar logo)
* @param string $alt Alternative text to use in the avatar image tag.
* @param array $args Arguments passed to get_avatar_data(), after processing.
*
* @return string
*/
function wp_kama_get_avatar_filter( $avatar, $id_or_email, $size, $default_value, $alt, $args ){
// filter...
return $avatar;
}
- $avatar(string)
- HTML for the user's avatar.
- $id_or_email(mixed)
- The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash, user email, WP_User object, WP_Post object, or WP_Comment object.
- $size(int)
- Height and width of the avatar in pixels.
- $default_value(string)
- URL for the default image or a default type. Accepts:
- '404' (return a 404 instead of a default image)
- 'retro' (a 8-bit arcade-style pixelated face)
- 'robohash' (a robot)
- 'monsterid' (a monster)
- 'wavatar' (a cartoon face)
- 'identicon' (the "quilt", a geometric pattern)
- 'mystery', 'mm', or 'mysteryman' (The Oyster Man)
- 'blank' (transparent GIF)
- 'gravatar_default' (the Gravatar logo)
- $alt(string)
- Alternative text to use in the avatar image tag.
- $args(array)
- Arguments passed to get_avatar_data(), after processing.
Changelog
| Since 2.5.0 | Introduced. |
| Since 4.2.0 | Added the $args parameter. |
Where the hook is called
get_avatar
wp-includes/pluggable.php 3353
return apply_filters( 'get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args );
wp-includes/pluggable.php 3255
return apply_filters( 'get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args );