Vill du ändra standard Gravatar på din WordPress site?
Om en comment inte har en Gravatar, kommer WordPress att visa samma grå ”mystiska person” som standard. Genom att ersätta denna standardbild med en image som du själv väljer kan du anpassa ditt comment section till ditt varumärke och få det att sticka ut.
I den här artikeln visar vi dig hur du ändrar standard Gravatar på WordPress.
Vad är en standard Gravatar och varför ändra den?
Gravatar står för Globally Recognized Avatar (globalt erkänd avatar). Det är en webbtjänst som allow människor att skapa en profil och associera avatar images med sin email address.
Alla WordPress webbplatser har inbyggt support för Gravatars och visar automatiskt användarens avatar när de skriver posts på en multi-site WordPress blogg eller lämnar comments.
Om en användare inte har en Gravatar visar WordPress en standard Gravatar istället. För de flesta WordPress-webbplatser är detta en grå mystisk person.
You can change this standard Gravatar to any other picture of your choosing. Du kan till exempel använda en image som representerar ditt företag, som logotypen för din website. Detta kan hjälpa till att förstärka your branding.
Med detta sagt, låt oss nu se hur du kan ändra standard Gravatar image på din WordPress website eller blogg. Använd bara snabblänkarna för att hoppa direkt till den metod du vill använda:
Metod 1: Välj en annan built-in WordPress Gravatar (snabbt och enkelt)
WordPress levereras med några olika standard Gravatars som du kan använda. Att använda standarderna är det snabbaste sättet att ändra den mystiska personens Gravatar, även om dessa images inte kommer att vara unika för din WordPress website eller varumärke.
För att se de olika standard Gravatars måste du gå till Settings ” Discussion från WordPress admin area.
Under ”Standard Avatar” ser du alla de olika built-in-avatarer som WordPress kan använda när det inte finns någon Gravatar linkad till personens email address.
Som standard använder WordPress den mystiska personen som standard, men du kan använda vilken annan image som helst i detta section.
Klicka helt enkelt på knappen bredvid den image som du vill använda på din WordPress blogg.
Därefter rullar du längst ner på vyn och clickar på ”Save Changes”.
Metod 2: Använd Thrive Comments för att ladda upp en anpassad Gravatar (Plugin Method)
Om du inte gillar alternativen för Gravatar som tillhandahålls av WordPress, kan du istället uploada en custom gravatar. Detta är det bästa sättet att anpassa din comment section till ditt varumärke.
För denna metod kommer vi att använda Thrive Comments. Det är ett plugin för kommentarer som är utformat för att uppmuntra användare att kommentera dina blogginlägg och öka engagemanget på din webbplats.
Förutom en custom Gravatar funktion, kommer Thrive Comments med tools för att göra din comment section roligare och mer spännande. Till exempel kan du aktivera likes och dislikes precis som på en social media site.
Du kan få Thrive Comments som ett enskilt plugin eller köpa den kompletta Thrive Themes Suite. Detta inkluderar alla Thrive-produkter, som Thrive Ovations, som kan förvandla dina kommentarer till rekommendationer.
Efter det kan du downloada ett zip-paket med plugin för att installera på din WordPress site. Läs vår Step-by-Step guide om hur du installerar ett WordPress tillägg för mer information.
När pluginet är installerat och aktiverat kan du gå till Thrive Dashboard ” Th rive Comments från WordPress admin area. Öppna sedan tabben ”Customize Style”.
Kontrollera att inställningen ”Display avatars” är aktiverad på den här tabben. När du har gjort det klickar du bara på ”Choose Image”.
Klart att du antingen kan välja en befintlig image från mediabiblioteket i WordPress eller uppladare din egen som standard Gravatar.
You can use a stock photo, make your own custom logo, or even create a new Gravatar image using web design software such as Canva. Denna image bör vara en square, gillar 250×250 pixlar.
När du har valt en image klickar du på ”Select”.
Och du är klar!
Du bör nu se din nya standard Gravatar i preview och på din live comment section.
Det coola med Thrive Comments är att du enkelt kan lazy load gravatars med det.
Det innebär att WordPress inte kommer att displayed en kommentators Gravatar förrän website besökaren rullar ner till den specifika kommentaren.
Om du vill aktivera den här funktionen går du helt enkelt till Thrive Dashboard ” Thrive Comments och öppnar tabben ”Advanced Settings”. Kryssa sedan av i boxen som säger ”Load avatar images when comment enter viewport.
Du kan också kryssa av de andra utvalda funktionerna för lazy loading.
För fler tips och tricks om hur du använder Thrive Comments, kontrollera dessa guider:
- Så här utväljer eller begraver du kommentarer i WordPress
- Så här redirectar du användarens uppmärksamhet med Comment Redirect
- Hur man tar bort fältet Website URL från formuläret WordPress Comment
Metod 3: Infoga ett code snippet för att använda en Custom Gravatar (kodmetod)
Förutom att använda Thrive Comments kan du också uploada en custom Gravatar med hjälp av kod. Du kanske föredrar den här metoden om du helt enkelt vill lägga till en new image i gravatarlistan på WordPress Discussion page.
Likes i den andra metoden, du måste ha en image som du vill använda som en Gravatar.
Efter det kan du ladda upp imagen till din WordPress site genom att gå till Media ” Add New. Här kan du antingen välja en image från mediabiblioteket i WordPress eller uppladare en new file från din dator.
Nu när du har valt en image kan du klicka på länken ”Edit” bredvid den.
WordPress öppnar nu filen för edit. På den här vyn rullar du till sektionen ”File URL”.
Obs/observera den här URL:en eftersom du behöver den i nästa steg.
I det här skedet måste du add to lite kod till din WordPress site. Ofta kommer tutorials att be dig att lägga till custom snippets till ditt temas functions.php-fil.
Vi rekommenderar dock inte detta eftersom även ett litet misstag i din kod kan orsaka vanliga WordPress error eller helt förstöra din website.
Det är därför vi rekommenderar att du använder WPCode. Det är det enklaste och säkraste sättet att add to custom code i WordPress utan att behöva edit några core WordPress-filer.
Det första du behöver göra är att installera och aktivera det gratis pluginet WPCode. För mer detaljer, se vår Step-by-Step guide om hur du installerar ett WordPress plugin.
Efter aktivering, gå till Code Snippets ” Add Snippet i din WordPress dashpanel.
Here, you will see all the different snippets you can add to your WordPress website. Dessa inkluderar snippets som tillåter dig att helt inaktivera comments i WordPress, uploada SVG-filer till din site, och mycket mer.
Eftersom vi lägger till ett custom snippet, hoverar du med musen över ”Add Your Custom Code” och klickar sedan på ”Use snippet”.
Börja med att enter en titel för det custom code snippet. Detta kan vara vad som helst som hjälper dig att identifiera snippet i WordPress dashboard.
Efter det måste du öppna ”Code Type” dropdown och klicka på ”PHP Snippet”.
När du har gjort det klistrar du helt enkelt in följande snippet i code snippets editor:
<?php
add_filter( 'avatar_defaults', 'wpb_new_gravatar' );
function wpb_new_gravatar($avatar_defaults) {
// Replace the URL below with your own Gravatar image URL
$myavatar = 'http://example.com/wp-content/uploads/2017/01/wpb-default-gravatar.png';
$avatar_defaults[$myavatar] = "Default Gravatar";
return $avatar_defaults;
}
?>
Glöm inte att ersätta URL:en med en länk till den image som du vill använda som standard WordPress Gravatar.
Under kodboxen kommer du att se några alternativ för infogning. Om det inte redan är valt väljer du metoden ”Auto Insert” så att snippet automatiskt infogas och körs på hela din site.
Därefter öppnar du dropdown ’Location’ och klickar på ’Run Everywhere’.
När du har gjort det måste du rulla högst upp på vyn och klicka på ”Inactive” toggle så att den ändras till ”Active” istället.
Slutligen, gå vidare och klicka på ”Save” för att göra Gravatar snippet live.
För att börja använda denna Gravatar, gå till Settings ” Discussion page.
I ”Default Avatar” section, välj det nya alternativet ”Default Gravatar”.
Efter det, se till att du klickar på ”Save Changes” för att lagra dina inställningar.
Nu, om du besöker din website, kommer du att se den nya standard Gravatar image live.
Så där ja! För att lära dig mer om Gravatars i WordPress, kontrollera dessa guider:
- Hur man visar Gravatar från användarens email i WordPress
- Så härinaktiverar du Gravatars i WordPress (Step-by-Step)
- Så här ändrar du storleken på Gravatar-imagen i WordPress
Vi hoppas att den här artikeln har hjälpt dig att lära dig hur du ändrar standard Gravatar på WordPress. Du kanske också vill se vår guide om hur du granskar kommentarer i WordPress och vår lista över de bästa tillägg för WordPress-kommentarer.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Syed Balkhi says
Hey WPBeginner readers,
Did you know you can win exciting prizes by commenting on WPBeginner?
Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
You can get more details about the contest from here.
Start sharing your thoughts below to stand a chance to win!
Dennis Muthomi says
The good thing I love about Thrive Comments is that uses a branded image as a placeholder icon for commenters without Gravatars.
Best comment plugin ever made!
Teri says
You did it again! You helped me. Thank you so much!
WPBeginner Support says
You’re welcome! Glad our guide was helpful!
Administratör
Francis says
Hi guys,
Wonderful tutorial, you saved me from a big headache! Keep up the great work!!!
Best regards,
Francis
WPBeginner Support says
Glad to hear our guide was helpful!
Administratör
Segun Solomon says
Thanks for this guide. It helps.
WPBeginner Support says
Glad it was helpful!
Administratör
WoodyP says
Hi, thank you for your article!
is there a way to assign one image per role?
WPBeginner Support says
We do not have a recommended method at the moment but if that changes we will be sure to share.
Administratör
Patti says
Been working for 2 days trying to get rid of the Chef Hat in my theme.
This worked! Thanks
WPBeginner Support says
Glad our guide could help
Administratör
Aardha says
This worked like a charm. Thanks!! Is there a way to have multiple default gravatar which can be assigned randomly to users ?
WPBeginner Support says
You would need a plugin for a feature like that, if we find a plugin we would recommend we will certainly share.
Administratör
David says
This is not working. WordPress does not allow to use local images. Please review your tutorial and update it accordingly.
WPBeginner Support says
The method should still be working, if you are on WordPress.com then that would be your issue as our guides are for WordPress.org. You can see the differences in our guide below:
https://www.wpbeginner.com/beginners-guide/self-hosted-wordpress-org-vs-free-wordpress-com-infograph/
Administratör
Murat Dinç says
Hi,
Can I add an icon instead of Adding an image?
WPBeginner Support says
You would want to check on Gravatar’s site for any current restrictions.
Administratör
Renz says
Thank you for this tutorial. was able to follow but my default picture wont show up
WPBeginner Support says
If our method was not able to assist, you would likely want to reach out to your theme’s support to ensure there isn’t a theme-specific setting preventing the change.
Administratör
Karen says
Okay, I found an easier solution for everyone that works well: just install the ”WP User Avatar” plugin. Works like a charm and you don’t have to do anything with coding!
WPBeginner Support says
Thanks for sharing your recommendation
Administratör
Mari Alonso says
This is great, thanks! I followed this by installing the plugin to add the code and then adding my 250×250 picture. It worked great, but now if anyone comments on my site, my picture, not theirs, shows up next to their name. My picture shows up everywhere and no one else’s. Any idea why?
Thank you.
WPBeginner Support says
That would be due to you setting the default gravatar for all users on your site. If you wanted to set a gravatar only for yourself you would want to use our guide here: https://www.wpbeginner.com/beginners-guide/what-is-gravatar-and-why-you-should-start-using-it-right-away/
Administratör
Thank you so much says
I followed the Gravatar instructions on your link and now anywhere I comment I see my unique Gravatar. Nevertheless, I see it everywhere except on my own site even thought the same email address is associated with it. Any ideas?
Thanks, tons again.
Mari
WPBeginner Support says
If you have any caching on your site make sure it is cleared as the most common reason for something like that.
Divine says
This page was really helpful. I managed to change the custom image. Thanks
WPBeginner Support says
Glad our recommendation could help
Administratör
Lilly says
Thank you for this post!! I use All in one SEO and could never get it to work. Your post provided a good map and work around. However I am still getting 12 error msgs? are they possible related?
WPBeginner Support says
It would depend on the specific errors. If you reach out to the plugin’s support they should be able to assist.
Administratör
Andreia Esteves says
Thank you for this post! But, what if I just want to change my personal avatar without using gravatar?
WPBeginner Support says
For just an author on your site, you would want to take a look at our article here: https://www.wpbeginner.com/plugins/how-to-add-an-authors-photo-in-wordpress/
Administratör
Giga says
I want an option where the user can upload an image as per their requirements. What should I do for that ?
WPBeginner Support says
It would depend on your specific requirements, for a starting point you would want to take a look at: https://www.wpbeginner.com/plugins/how-to-allow-users-to-upload-images-with-comments-in-wordpress/
Administratör
Tommy Roche says
Thank you for this.
WPBeginner Support says
You’re welcome
Administratör
Mahdi says
ty – its worked for me – but now default avatar loded from other site – how i can define that this image loaded from my host?
WPBeginner Support says
You’re likely using the Jetpack plugin and using their option to load images from their server. You can go into Jetpack’s settings to disable this function.
Administratör
MAHDI says
i don’t have Jetpack plugin – how i can do it? without install new plugin?
WPBeginner Support says
If you mean you want your gravatar image to be loaded from your site when it is added to other sites, that is not an option at the moment.
Daniel says
Perfect solution, thank you!
WPBeginner Support says
You’re welcome
Administratör
Divya S says
That was so informative!
Brian says
Hey so I have sort of a peculiar yet distinct task that I need help with. My client has a blog on WordPress but then they post their blog to Twitter, next to the article is a gray blank avatar. She had requested that I find a way to put some sort of image in place of this but I am not sure how to go about doing this. I know she uses a Gravatar for the comment section but this instance is a bit different. Any advice on what I can do?
Ryô says
Hello, the code works well, but I made some changes to my newly added avatar picture and I still see the first version when I refresh the page.
Looking at the url of the picture it automatically added ”http://i2.wp.com/” at the beginning (I don’t have jetpack or any cache plugins).
I guess I can just change the name of my picture and update the code, but is it a way to get ride of wp cache?
Satyam Patle says
Wow Thank you sir its helping me for Change custom Avtar
Ana says
I have no problem changing the image on my gravatar but I cannot seem to change the words. Even though I select edit and rewrite them, the change doesn’t appear on my wordpress site. What am I doing wrong?
anna says
Thanks for the nice explanation, Now I’m clear about setting up my gravatar in WordPress site.
rashmi says
this is very useful
Pat says
Thank you, thank you, thank you! I’ve looked everywhere on how to change the default avatar and you were the only ones who simple explained it and displayed how! Sometimes finding the answer in the haystack of information can be just mind blowing. You rock!
manoj rai says
how set when user comment your post show him/her original profile. please help me. thanks
Joy says
Hello, I’ve tried this in my child’s theme function and it just will not work. The image in the discussion settings and on the front-end appear broken. When I right click to view the path it displays:
It affixes the i1.wp.com before the link. Even when I tried to connect directly to the child theme stylesheet directory and pickup from the folder, ’images/chicken_avatar.png’, it still affixed the i1.wp.com
Any ideas how to fix this? Thank you.
WPBeginner Support says
Hey Joy,
We tested it again with a child theme and it worked as expected. We are not sure what may be causing the issue. You can follow the instructions again. Make sure you add the full image URL in the code.
Administratör
Joy says
Hmm, not sure what I was doing wrong. I just gave it another go and it works. Thank you!
Andrew says
Joy: Mine Via Another WordPress Script, is Going to (i0.wp.com/MySite…). Very Strange. :–)
Andrew says
It Still Shows i0.wp.com/MySite Whwn Going to the Image Location, but I Changed the URL Code to (’/custom-gravatar/mh-profile-photo-default.png’), Instead of ’example.com/wp-content/uploads/2017/09/mh-profile-photo-default.png’). In Settings > Discussion It Shows My Admin Photo as the Default User Gravatar, but On User Profiles, It Views Properly! :–)
Mayaprakash Pant says
Hello.
The code worked perfectly fine for me. But this arises another problem:
Same gravatar appears when everyone else including visitor comments on my blog.
How to solve this?
Gabrielle says
Hi, i added and sucesfully saved input(type = url) for each user profile, on ly localhost installation.
I’m trying to change original code from WP Codex wesbsite:
From:
add_filter( ’avatar_defaults’, ’new_default_avatar’ );
function new_default_avatar ( $avatar_defaults ) {
//Set the URL where the image file for your avatar is located
$new_avatar_url = get_bloginfo( ’template_directory’ ) . ’/images/new_default_avatar.png’;
//Set the text that will appear to the right of your avatar in Settings>>Discussion
$avatar_defaults[$new_avatar_url] = ’Your New Default Avatar’;
return $avatar_defaults;
}
To something that will replace default avatar url foreach user with value from custom input field(if its not empty), any help?
I know there are plugins that allows subsciribers to upload gravatar images, but i don’t want to allow them doing that, i want to give them a chance to put url to their own images
Manish B says
I am not able to show avatars next to comments. I am using Hitchcock WordPress Theme.
Claire Benneth says
THANK YOU!
Actually I’ve been looking for this solution for my blog for 3 months!
Thanks again!
Claire xo
Jen Hardy says
I have the Gravatar set up in WordPress, but when the e-mail goes out to my followers for my blog, the mystery man is there. Looks really bad at the top of my e-mail. Any suggestions?
Thanks!
Syed Hamza says
Here are two folders of images in Cpanel.
1. /public_html/wp-includes/images
2. /public_html/wp-content/themes/divi/images
In which folder where I upload the image.
Manoj says
I can’t see my avatar even after setting in comment box but i see it about me.
Manish B says
I am facing the same issue.
Michael says
I’m looking for a plugin, or SIMPLE code solution that will allow me to create a number of ’default’ gravatar/avatar images that are color coded based on the member’s gender/orientation. Obvious ones like blue for male, pink for female, but I’ll likely add lavender for transgender and possibly others. Basically, the decision about the ’default’ avatar that appears for the member (until they upload an image) would at least let people browsing the site know if the person they see posting (or online) is male / female / transgender / etc.. Any ideas?
Me says
Is there code to force the default avatar to be blank? I have it set to blank in the WP settings, but it’s still showing up as mystery man. Is there code to either delete mystery man entirely so it’s not even an option. Or to make sure it’s blank and not mystery man? Thanks!
WPBeginner Support says
See our guide how to disable gravatars in WordPress.
Administratör
Me says
Thanks! I tried that already. When I do that, the avatars also disappear from the author box (I’m using Starbox). I’m at a loss. I’ve even checked my WP tables, and it shows the default avatar is set to blank. I can’t figure out how to get rid of mystery man…
Michael says
How would one go about rotating a set of images in that Gravatar thumbnail spot? Meaning: if I had 5 different images, to have them randomly appear for users without Gravatars, so there was a variation of the 5?
Angelica Costa says
If anyone is facing issues with child themes, just use:
$myavatar = get_stylesheet_directory_uri().’/img/favicon.png’;
It works.
Mark says
This was a life saver!
Julia says
Great, thanks!
Gina Smith says
Thanks for the information!
Keely says
Wow – found this post 2 years after my first post and got it working this time![:)](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%200%200'%3E%3C/svg%3E)
Thanks WP Beginner
Caroline says
Thanks!
chris007 says
okay i get the whole idea but how you put your personal pciture of you into the gravatar that what i’m trying to figure out..
Thomas says
Goto Gravatar website and sign in with WordPress. Then you can upload your avatar and tie it to one or more of your emails.
Alex says
Thank you!
Karan Rawat says
It works. Thanks Bookmarked your blog!
Chuks Emmanuel says
Thank you Syed Balkhi. it really worked for me. just keep the good work going.
Adrian O'Farrell says
Hi, just checking what happens next
Simen Eggen says
Thank you so much
it’s working
Sadia says
Thank you so much for these instructions. For some reason, things were wonky when I used a .png file, but a gif worked easy peasy!