WPDev.one
Core Function
View Source on Trac ↗

get_avatar()

get_avatar( mixed $id_or_email, mixed $size = 96, mixed $default_value = '', mixed $alt = '', mixed $args = null )

Retrieves the avatar `<img>` tag for a user, email address, MD5 hash, comment, or post.

Parameters 4 required

Name / Type Description
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.

Required
$size
int

Optional. Height and width of the avatar in pixels. Default 96.

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) Default is the value of the 'avatar_default' option, with a fallback of 'mystery'.

Required
string

$alt Optional. Alternative text to use in the avatar image tag. Default empty.

Required
array

$args { Optional. Extra arguments to retrieve the avatar.

Required

Return Value

((string)
| false) `<img>` tag for the user's avatar. False on failure.

Function Information

Since Version
2.5.0
Source File
wp-includes/pluggable.php
Advertisement