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)

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.

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

The default Gravatar in WordPress

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.

Changing the default Gravatars in WordPress

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.

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

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.

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

Choosing a custom gravatar in Thrive Comments

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

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

Och du är klar!

Du bör nu se din nya standard Gravatar i preview och på din live comment section.

Example of a comment after the Thrive Comments plugin is activated

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.

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.

Eftersom vi lägger till ett custom snippet, hoverar du med musen över ”Add Your Custom Code” och klickar sedan på ”Use snippet”.

Showing a custom avatar using code

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

How to add a PHP snippet in WordPress

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

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

How to activate the gravatar code snippet

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

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.

Nu, om du besöker din website, kommer du att se den nya standard Gravatar image 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 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.

Avslöjande: Vårt innehåll stöds av våra läsare. Det innebär att om du klickar på några av våra länkar, kan vi tjäna en provision. Se hur WPBeginner finansieras, varför det är viktigt, och hur du kan stödja oss. Här är vår editoriala 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.

Den ultimata WordPress-verktygslådan

Få GRATIS tillgång till vår verktygslåda - en samling WordPress-relaterade produkter och resurser som varje professionell användare bör ha!

Reader Interactions

119 kommentarerLämna ett svar

  1. 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!

  2. 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! :-)

  3. Francis says

    Hi guys,

    Wonderful tutorial, you saved me from a big headache! Keep up the great work!!!

    Best regards,

    Francis

    • 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

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

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

      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

  6. 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!

  7. 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. :-)

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

  9. Andreia Esteves says

    Thank you for this post! But, what if I just want to change my personal avatar without using gravatar?

  10. Giga says

    I want an option where the user can upload an image as per their requirements. What should I do for that ?

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

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

  12. 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?

  13. 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?

  14. 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?

  15. 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!

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

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

  17. 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?

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

  19. Claire Benneth says

    THANK YOU!

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

    Claire xo

  20. 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!

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

  22. 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?

  23. 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!

  24. 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?

  25. Angelica Costa says

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

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

    It works.

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

  26. 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!

Lämna ett svar

Tack för att du väljer att lämna en kommentar. Tänk på att alla kommentarer modereras enligt våra policy för kommentarer, och din e-postadress kommer INTE att publiceras. Vänligen använd INTE nyckelord i namnfältet. Låt oss ha en personlig och meningsfull konversation.