Title: Problems with get_avatar()
Last modified: August 31, 2016

---

# Problems with get_avatar()

 *  [pajohns](https://wordpress.org/support/users/pajohns/)
 * (@pajohns)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/problems-with-get_avatar/)
 * I am trying to retrieve an avatar using the following:
 * `<?php echo get_avatar( get_the_author_email(), 96); ?>`
 * however the code that this line returns is this:
 * `<img src="http://www.gravatar.com/avatar.php?gravatar_id=e79af5d67f65c94861fee01562971802&
   size=40" alt="philip@marketdental.com.au'" height="64" width="64">`
 * Firstly the height of 64×64 – where did this come from? Also you’ll notice that
   in the avatar.php file it is passing a size value of 40 in, so even at 64 the
   image appears very poor quality. If I modify these values to be size=96 and then
   change the height and width to be 96 then it works fine – just can’t figure out
   where I’m going wrong?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [jejani](https://wordpress.org/support/users/jejani/)
 * (@jejani)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/problems-with-get_avatar/#post-7148165)
 * [@pajohns](https://wordpress.org/support/users/pajohns/),
 * There is some info missing here, like if you are using a premium theme that is
   involved here, etc. You can learn more about the default gravatar behavior here:
 * [https://codex.wordpress.org/Function_Reference/get_avatar](https://codex.wordpress.org/Function_Reference/get_avatar)
 * If you are talking about raw code on a custom theme, try (i.e.):
 *     ```
       <div class="gravatar" style="background-image:url(https://www.gravatar.com/avatar/<?php
       $authoremail = get_the_author_meta('user_email');
       echo md5(strtolower(trim($authoremail)));
       ?>?s=96)"></div><!-- end gravatar -->
       ```
   
 * Better to use it as a CSS element background and not a true image in my opinion,
   then you will retain more control over style, and then the gravatars will not
   be scraped by social media sites for sharing, etc.
 * Keep in mind the difference between CSS height, HTML height, and then the actual
   image’s height (called by the `?s=XX` query in the gravatar’s URL).
 *  Thread Starter [pajohns](https://wordpress.org/support/users/pajohns/)
 * (@pajohns)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/problems-with-get_avatar/#post-7148168)
 * Hi Jejani,
 * I’m not using a premium theme – made it myself, so pretty basic functionality.
   Apart from styling your div with the gravatar as a bkg image the way you’ve done
   it is similar to how I ended up getting it to work. The code I used is:
 *     ```
       <?php $authorHash = md5(get_the_author_email());
       $authorHash = trim($authorHash);?>
       <div class="post-thumb mb-0"><img class="img-thumbnail" src="http://www.gravatar.com/avatar/<?php echo $authorHash; ?>?s=128" width="128" height="128" /></div>
       ```
   
 * I’ll incorporate styling the div background, however what I’m wondering is why
   we can’t use the get_avatar function that wordpress provides. I mean it does 
   work, but the quality is terrible!
 *  [Ross Wintle](https://wordpress.org/support/users/magicroundabout/)
 * (@magicroundabout)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/problems-with-get_avatar/#post-7148173)
 * Hi [@pajohns](https://wordpress.org/support/users/pajohns/)
 * The `get_avatar()` function is both filterable (you can hook a filter function
   to it) and pluggable (you can replace it entirely with a function in a plugin),
   so there’s lots of opportunity for the output to get mangled. I’d ask what plugins
   you have installed and if any of them might be modifying the avatar output.
 * Do you get the same poor quality output if you disable all your plugins?
 * Ross

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Problems with get_avatar()’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [Ross Wintle](https://wordpress.org/support/users/magicroundabout/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/problems-with-get_avatar/#post-7148173)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
