Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Så här ändrar du standard Gravatar på WordPress (enkel guide)

Den generiska ”mystiska personen”-avataren i ditt WordPress-kommentarfält gör inte din webbplats någon tjänst. Efter att ha byggt hundratals WordPress-webbplatser vet vi hur ett personligt kommentarsfält kan göra din webbplats mer engagerande och professionell.

Oavsett om du vill använda din varumärkeslogotyp, en anpassad design eller bara något mer tilltalande än den grå standardsilhuetten, är det ett enkelt sätt att förbättra din webbplats utseende att ändra din standardgravatar. Och det bästa av allt? Du behöver inte vara en teknisk expert för att göra den här ändringen.

I den här guiden visar vi dig flera sätt att ersätta standardgravataren i WordPress

How to change the default Gravatar on 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 stöd för gravatarer och kommer automatiskt att visa användarens avatar när de skriver inlägg på en WordPress-blogg med flera författare eller lämnar kommentarer.

Om en användare inte har någon gravatar kommer WordPress att visa en standardgravatar i stället. För de flesta WordPress-webbplatser är detta en grå mystisk person.

The default Gravatar in WordPress

Du kan ändra denna standardgravatar till en annan bild som du själv väljer. Du kan till exempel använda en bild som representerar ditt företag, som din webbplatslogotyp. Detta kan hjälpa till att förstärka ditt varumärke.

I vårt fall bestämde vi oss för att inaktivera gravatars helt eftersom vi tyckte att det skapar ett onödigt extra steg för användare som vill lämna kommentarer.

WPBeginner's comment section

Med det sagt, låt oss se hur du kan ändra standardgravatarbilden i WordPress. Använd bara snabblänkarna för att hoppa direkt till den metod du vill använda:

Metod 1: Ändra standard WordPress Gravatar (snabbt och enkelt)

WordPress levereras med några olika standardgravatarer som du kan använda. Att använda standardinställningarna är det snabbaste sättet att ändra den mystiska personens gravatar, även om dessa bilder inte kommer att vara unika för din WordPress-webbplats eller ditt varumärke.

För att titta på de olika standardgravatarerna måste du gå till Inställningar ” Diskussion från WordPress-adminområdet.

Changing the default Gravatars in WordPress

Under ”Standardavatar” ser du alla de olika användaravatarbilder som WordPress kan använda när det inte finns någon gravatar kopplad till personens e-postadress.

Som standard använder WordPress den mystiska personen som standard, men du kan använda vilken annan image som helst i detta section.

The built-in WordPress Gravatars

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”.

Clicking the 'Save Changes' button on the WordPress Discussion settings page

Metod 2: Använd Thrive Comments för att ladda upp en anpassad Gravatar (Plugin Method)

Om du inte gillar standardprofilbilderna på WordPress kan du ladda upp en egen gravatar i stället. Detta är det bästa sättet att anpassa ditt kommentarsfält 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.

The Thrive Comments WordPress plugin

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.

Därefter kan du ladda ner ett zip-paket med plugin för att installera på din WordPress-webbplats. Läs vår kompletta guide om hur du installerar ett WordPress-plugin 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”.

Choosing a custom gravatar in Thrive Comments

Här kan du antingen välja en befintlig bild från WordPress mediebibliotek eller ladda upp en egen bild som du vill använda som standardbild för Gravatar.

Du kan använda ett stockfoto, skapa din egen logotyp eller till och med skapa en ny gravatarbild med hjälp av ett webbdesignprogram som Canva. Den här bilden ska vara kvadratisk, till exempel 250×250 pixlar.

När du har valt en image klickar du på ”Select”.

Selecting a gravatar image in the WordPress media library using Thrive Comments

Och du är klar!

Du bör nu se din nya standardprofilbild gravatar i förhandsgranskningen och i ditt livekommentaravsnitt.

Example of a comment after the Thrive Comments plugin is activated

Det häftiga 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.

Enabling lazy loading in Thrive Comments

För fler tips och tricks om hur du använder Thrive Comments, kontrollera dessa guider:

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.

How to upload a custom default Gravatar in WordPress

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”.

Uploading a default WordPress Gravatar

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.

How to add a custom avatar snippet to your WordPress website

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.

Det finns till och med en för att använda en anpassad bild för standardavataren. Sök bara efter utdraget ”Custom Default Avatar” i biblioteket.

När du har hittat det, håll muspekaren över det och klicka sedan på knappen ”Använd snippet”.

Showing a custom avatar using code

Efter det kommer WPCode automatiskt att lägga till rätt kod åt dig.

Glöm inte att ersätta URL:en med en länk till den bild som du vill använda som standardgravatar för WordPress.

WPCode automatically adds the code, you just need to replace the image url

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’.

How to run PHP gravatar code across your website

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å ”Uppdatera” för att göra gravatar-snippet live.

How to activate the gravatar code snippet

För att börja använda den här gravataren, gå till sidan Inställningar ” Diskussion.

I avsnittet ”Standardavatar” väljer du det nya alternativet ”Anpassad avatar”.

How to change the default Gravatar in WordPress

Efter det, se till att du klickar på ”Save Changes” för att lagra dina inställningar.

Om du nu besöker din webbplats kommer du att se den nya standardgravatarbilden live.

An example of a custom defualt Gravatar, on a WordPress website

Så där ja! För att lära dig mer om Gravatars i WordPress, kontrollera dessa guider:

Vi hoppas att den här artikeln har hjälpt dig att lära dig hur du ändrar standardgravatar på WordPress. Du kanske också vill se vår guide om hur du modererar kommentarer i WordPress och vår lista över de bästa WordPress-kommentarpluginsen.

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.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

118 kommentarerLeave a Reply

  1. anna

    Thanks for the nice explanation, Now I’m clear about setting up my gravatar in WordPress site.

  2. rashmi

    this is very useful

  3. Pat

    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!

  4. manoj rai

    how set when user comment your post show him/her original profile. please help me. thanks

  5. Joy

    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

      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.

      Admin

      • Joy

        Hmm, not sure what I was doing wrong. I just gave it another go and it works. Thank you!

    • Andrew

      Joy: Mine Via Another WordPress Script, is Going to (i0.wp.com/MySite…). Very Strange. :–)

      • Andrew

        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! :–)

  6. Mayaprakash Pant

    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?

  7. Gabrielle

    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

  8. Manish B

    I am not able to show avatars next to comments. I am using Hitchcock WordPress Theme.

  9. Claire Benneth

    THANK YOU!

    Actually I’ve been looking for this solution for my blog for 3 months!
    Thanks again!

    Claire xo

  10. Jen Hardy

    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!

  11. Syed Hamza

    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.

  12. Manoj

    I can’t see my avatar even after setting in comment box but i see it about me.

    • Manish B

      I am facing the same issue.

  13. Michael

    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?

  14. Me

    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!

      • Me

        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…

  15. Michael

    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?

  16. Angelica Costa

    If anyone is facing issues with child themes, just use:

    $myavatar = get_stylesheet_directory_uri().’/img/favicon.png’;

    It works.

    • Mark

      This was a life saver!

    • Julia

      Great, thanks!

  17. Gina Smith

    Thanks for the information!

  18. Keely

    Wow – found this post 2 years after my first post and got it working this time :)
    Thanks WP Beginner

  19. chris007

    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

      Goto Gravatar website and sign in with WordPress. Then you can upload your avatar and tie it to one or more of your emails.

  20. Karan Rawat

    It works. Thanks Bookmarked your blog!

  21. Chuks Emmanuel

    Thank you Syed Balkhi. it really worked for me. just keep the good work going.

  22. Adrian O'Farrell

    Hi, just checking what happens next

  23. Simen Eggen

    Thank you so much :) it’s working :D

  24. Sadia

    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!

  25. Katelyn

    I am having the same issue as Keely. I am using a child theme so get_bloginfo does not work. When I check the URL of the broken image it displays the path to the parent theme. Is there a way to get this to work with a child theme?

  26. Akash KB

    What should be the size of the image file to be uploaded to the theme folder?

    Thanks :)

  27. Brody

    Any way to make this use a SSL connection using the same code? Always loads ”insecure content”. What changes to make it a secure image during loading?

    • WPBeginner Support

      If you are loading gravatar on a secure page then it should automatically load securely. Also check Settings » General change your site and WordPress address to use https. Let us know if this solved the issue.

      Admin

  28. Pavan Deshpande

    Thank you for sharing this , i was not able to change the default image but after reading this i changed

  29. Keely

    What if you’re using a child theme …

    I changed the line
    $myavatar = get_bloginfo(’template_directory’) . ’/images/gravataricon.gif’;
    to
    $myavatar = get_bloginfo(’stylesheet_directory’) . ’/images/gravataricon.gif’;

    but still not working :(

    • Editorial Staff

      Is the image not showing or the code altogether is not working (i.e it’s not even adding an option for custom gravatar)?

      Admin

      • Kristen

        I am having issues with the code also. I used it on another site and it worked perfectly, however on the site I’m currently working on… it shows as an option in the admin panel under settings-discussion, however it is showing as a broken image and does not display on the blog pages either. Any help is greatly appreciated.

        • Editorial Staff

          Right click on the broken image to get the image URL. Open that URL in another tab to verify that the URL is correct.

  30. Rachel

    I just used your advice here; more explanation that the image needed to be saved in the themes folder too would have been helpful. But your tips here helped me figure some of it out. Thanks.

  31. mrahmadawais

    @wpbeginner Secondly , do you know an good pre image loading plugin for wordpress

  32. mrahmadawais

    @wpbeginner disquess is having some problems at my blog see there http://freakify.com it is not allowing me to upload any custom image>>>? Why

  33. wpbeginner

    @mrahmadawais That is because Disqus is a third party platform….

  34. mrahmadawais

    tell me plz

  35. mrahmadawais

    any one here now to tell me why disquss is not accpting this

  36. Shabil Team

    This gravatar custom code is very cool and really work on my blog. Thank you very much.

    You rock WPbeginner.

  37. Shabil Team

    This gravatar custom code is very cool and really work on my blog. Thank you very much.

    You rock WPbeginner.

  38. wpbeginner

    @Kindar We are glad to have you as a user :) Let us know if you have any suggestions.

  39. Kindar

    When ever I search for something on the internet i usually get to see your website.. Now I started follow your website and the stuff you share.. What ever you share its really useful and thats why i always check it up, and see whats new. Also i wanted to thank you for the last subject.

  40. Kindar

    When ever I search for something on the internet i usually get to see your website.. Now I started follow your website and the stuff you share.. What ever you share its really useful and thats why i always check it up, and see whats new. Also i wanted to thank you for the last subject.

  41. iur

    where is located the file /images/gravataricon.gif ?

  42. Cee

    Hi!
    Wow..I’ve gone round and round with code. Not adept with this as a newb…but usually can get things to work.
    I added the code to get a default avatar for guest . It worked. At least in admin. The image shows up in ADMIN..but not on the website.

    I also signed up at gravatar for my own custom gravatar for my ADMIN comments…and it shows up in their ”check point”…but cannot get it to show up in my comments.

    Neither does the Guest Gravatar.. but the GRAVATAR image shows up instead.
    My custom image IS checked as default in Discussions. Both images are uploaded to the theme/images and the path to the guest image is correct in the code. I made the images 128 x 128 as suggested online nowadaZe… Dunno if THAT sizing must be specified somewhere? I looked thru the functions code…as best as my bewildered eyes can comprehend..but didn’t finding anything that looked like it would work. Maybe in style.css?… Dunno if it makes a difference. Don’t want to go thru changing everything..and still not work. Have already spent DAYS trying to figure this out. Should be a simple thing.

    Don’t understand why MY admin gravatar isn’t showing. Per what I read…it should be handled via gravatar. The email address used for the gravatar is the same as listed in admin.

    WHAT am I doing wrong/missing?.. I have WP 2.8.4.
    I tried pasting the above code at the top…AND at the bottom… but neither works. Does it matter WHERE you paste it in the functions.php?

    Can you suggest anything?Would DEEPLY appreciate any help you can give. Can give you any code you might need…just specifiy.

    Thank you in advance. tearing out hair..

    • Editorial Staff

      It sounds like that this issue is not with the function rather it is the comments.php file error.

      Admin

  43. Louis Gubitosi

    thanks for this tip. I used this on my site and the default avatar is showing up in the comments section but not in the ”Recent Comments” side bar. I’m using the ”Get Recent Comments” plugin. Is this treated differently?

    http://interactiveblend.com/blog

    • Editorial Staff

      Unless that plugin has specified a default in their code, this should work. It means the plugin is not coded properly. Contact the developer, and ask them to fix it.

      Admin

  44. martin

    The code works if placed in custom-php.php which has the advantage of sticking through upgrades.

    Do you have any ideas on the code for removing the html calls to gravitar.com in buddypress?

  45. JD

    Thanks for the tip. Works flawlessly.

  46. Desik

    I noticed wordpress is changing the quote into a backquote, you should use ' instead of

  47. fantasmo

    This is the code snippet I was looking for.
    But it doesn’t work properly… I put in the code into my functions.php (I’m sure everything is correct, also the path to my picture).

    But when I go to discussion, I can’t see my Avatar, and also the WP-backend is a little bit broken… The code i put into the functions.php shows up above the header of the WP-backend.

    Can you help me please? Maybe I didn’t only a little thing wrong??

    • Editorial Staff

      The code above is 100% correct because that is what we are using. I don’t know what you can potentially be doing wrong. But without looking at your codes we won’t be able to help you out. You can hire us for a small fee, and our staff can surely fix the problem.

      Admin

      • Tracy

        I think I may be having the same trouble as fantasmo. The snippet works and the gravatar shows up within the discussion admin page but when you click on ’save changes’ to save the options, you get a white screen which displays the footer from the option-discussions.php instead of the full page saying that the options have been saved.

    • CC Rogers

      I saw the same results as Fantasmo. When I copy/pasted the code, the blank line between the add_filter and the function was lost for some reason. Putting the blank line back seemed to fix the problem.

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.