Codex

Function Reference/get avatar

Contents

Description

Retrieve the avatar for a user who provided a user ID or email address. Most commonly used in the comments section.

This function is also pluggable.

Usage

 <?php echo get_avatar$id_or_email$size$default$alt ); ?> 

Parameters

$id_or_email
(int/string/object) (required) Author’s User ID (an integer or string), an E-mail Address (a string) or the comment object from the comment loop. Note: with most comment templates you can use $comment here, in order to display the gravatar of the commenter. In other templates within The Loop (for WordPress 2.7 and lower), you can use get_the_author_id() (deprecated in WordPress 2.8). For WordPress 2.8, please use get_the_author_meta('user_email').
Default: None
$size
(integer) (optional) Size of Gravatar to return (max is 512).
Default: 96
$default
(string) (optional) url for an image, defaults to the "Mystery Man".
Default: None
$alt
(string) (optional) Alternate text for the avatar.
Default: None

Examples

<?php echo get_avatar( $comment, 32 ); ?>

Change Log

  • Since: 2.5.0

Source File

get_avatar() is located in wp-includes/pluggable.php.

Related

This article is marked as in need of editing. You can help Codex by editing it.
See also index of Function Reference and index of Template Tags.