Default wordpress provide you gravatar for admin profile picture. I am also stuck with this issue that how i can change admin bar profile picture and remove gravatar from wordpress site. cause gravatar means you are calling a remote url for getting image on each time. may be it’s effecting our site page speed. so i have search many time for this and not found a good solution. for solve this i have coded manually. after that i can see my new image for my blog admin.
Let’s see how to remove gravatar from wordpress and setting new admin profile picture.
1. Go to “wp-includes/pluggable.php” and find below code (under function get_avatar()):-
$avatar = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
And replace it with below code :-
$get_admin_user = get_user_by_email($email);
if(is_super_admin($get_admin_user->ID)) {
if(($useravatar = get_user_meta($get_admin_user->ID, 'admin_user_thumbnail', true)) !== false AND strlen(trim($useravatar)) > 0){
$avatar = "<img alt='{$safe_alt}' src='".get_template_directory_uri().$useravatar."' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
}
}
else {
$avatar = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
}
2. Add or insert new row in user_meta table in your database.
user_id = 1 //admin userid if any other
meta_key = admin_user_thumbnail
meta_value = /images/myadminimage.png // give a path "your_active_theme/images"
3. upload your admin image(myadminimage.png) in “wp-content/themes/your_active_theme/images/”.
Now refresh your site you will get new image on admin bar and every where you have admin profile pic on site. so this is a manually doing simple method to change profile picture in wordpress.