# Your Own Image as the Default Avatar

> Adds your own image to the Default Avatar choices under Settings > Discussion, used for people without a Gravatar.

- Type: PHP
- Runs: Run everywhere
- Category: [Users](https://wpide.com/library/category/users/)
- Tags: users, avatars, branding
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/custom-default-avatar/

## Code

```php
// Full URL of the default avatar image (square, at least 256px).
$wpide_default_avatar_url  = 'https://example.com/wp-content/uploads/default-avatar.png';
$wpide_default_avatar_name = 'Site avatar';

add_filter( 'avatar_defaults', function ( $defaults ) use ( $wpide_default_avatar_url, $wpide_default_avatar_name ) {
    $defaults[ $wpide_default_avatar_url ] = $wpide_default_avatar_name;

    return $defaults;
} );
```

## Notes

After activating, choose the new avatar in Settings > Discussion (Gravatar must be able to reach the image URL).

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Your Own Image as the Default Avatar" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
