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.
Opens WPIDE on
Code
// 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 add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.