Title: rest_get_avatar_urls
Published: December 7, 2016
Last modified: August 20, 2026

---

# rest_get_avatar_urls( mixed $id_or_email ): (string|false)[]

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/rest_get_avatar_urls/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/rest_get_avatar_urls/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/rest_get_avatar_urls/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/rest_get_avatar_urls/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/rest_get_avatar_urls/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/rest_get_avatar_urls/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/rest_get_avatar_urls/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/rest_get_avatar_urls/?output_format=md#wp--skip-link--target)

Retrieves the avatar URLs in various sizes.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/rest_get_avatar_urls/?output_format=md#description)󠁿

### 󠀁[See also](https://developer.wordpress.org/reference/functions/rest_get_avatar_urls/?output_format=md#see-also)󠁿

 * [get_avatar_url()](https://developer.wordpress.org/reference/functions/get_avatar_url/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/rest_get_avatar_urls/?output_format=md#parameters)󠁿

 `$id_or_email`mixedrequired

The avatar to retrieve a URL for. Accepts a user ID, Gravatar MD5 hash, user email,
[WP_User](https://developer.wordpress.org/reference/classes/wp_user/) object, [WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)
object, or [WP_Comment](https://developer.wordpress.org/reference/classes/wp_comment/)
object.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/rest_get_avatar_urls/?output_format=md#return)󠁿

 (string|false)[] Avatar URLs keyed by size. Each value can be a URL string or boolean
false.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/rest_get_avatar_urls/?output_format=md#source)󠁿

    ```php
    function rest_get_avatar_urls( $id_or_email ) {
    	$avatar_sizes = rest_get_avatar_sizes();

    	$urls = array();
    	foreach ( $avatar_sizes as $size ) {
    		$urls[ $size ] = get_avatar_url( $id_or_email, array( 'size' => $size ) );
    	}

    	return $urls;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rest-api.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/rest-api.php#L1307)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/rest-api.php#L1307-L1316)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/rest_get_avatar_urls/?output_format=md#related)󠁿

| Uses | Description | 
| [rest_get_avatar_sizes()](https://developer.wordpress.org/reference/functions/rest_get_avatar_sizes/)`wp-includes/rest-api.php` |

Retrieves the pixel sizes for avatars.

  | 
| [get_avatar_url()](https://developer.wordpress.org/reference/functions/get_avatar_url/)`wp-includes/link-template.php` |

Retrieves the avatar URL.

  |

| Used by | Description | 
| [WP_REST_Users_Controller::prepare_item_for_response()](https://developer.wordpress.org/reference/classes/wp_rest_users_controller/prepare_item_for_response/)`wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php` |

Prepares a single user output for response.

  | 
| [WP_REST_Comments_Controller::prepare_item_for_response()](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/prepare_item_for_response/)`wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php` |

Prepares a single comment output for response.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/rest_get_avatar_urls/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.7.0](https://developer.wordpress.org/reference/since/4.7.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Frest_get_avatar_urls%2F)
before being able to contribute a note or feedback.