• Resolved Pixel Industry

    (@pixel-industry)


    Hi,

    I am using in my themes get_avatar() call to fetch author’s image. I tried your plugin and it won’t show the image though it’s working fine on comments and all other places. I took a time and fixed this issue.

    Problem was in function ‘get_easy_author_image’. Function ‘get_avatar’ can pass as first argument users ID or E-Mail (object). Situation when user pass ‘user_id’ as argument wasn’t handled so I changed a function to support this.
    This is good because users now can use standardized way to fetch avatar (they don’t need to use get_author_image_url() function) and if they decide to remove the plugin, their theme will work fine (no need to remove the calls to get_author_image_url()).

    Here is the code.
    Note that code I added was partly taken from WordPress ‘get_avatar()’ function. That’s how they do it.

    Vladimir

    https://www.ads-software.com/plugins/easy-author-image/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Lawsonry

    (@lawsonry)

    Vladimir,

    Outstanding! I’ll be adding this code into the next release.

    – Jesse

    Plugin Author Lawsonry

    (@lawsonry)

    I’m going to credit “Vladimir from Pixel Industry” — is that okay?

    Thread Starter Pixel Industry

    (@pixel-industry)

    Sure ?? Glad to help!

    I’m also using Jetpack comments and for some reason when I use get_avatar($comment); it only shows the gravatar logo and doesn’t pull in the visitors gravatar if they don’t have an uploaded image or aren’t using other social comments.

    Before I submit the comment it shows a preview of the gravatar that will show but when I submit the comment only the default gravatar logo shows up.

    Here’s my test site link with some comments that are defaulting to the gravatar logo only.
    https://lancewilliams.me/gurus/nutrition/army-had-half-a-day/

    I love the plugin and I’m probably just missing something simple.

    Thanks for the hard work!

    After some testing I was able to get everything working.
    In easy-author-image.php I changed the $gravatarUrl line where the $email is empty to:

    $gravatarUrl = “https://www.gravatar.com/avatar/” . md5($email) . “&size=40”;

    For some reason $email->comment_author_email was returning null. Probably had something to do with Jetpack comments or something.
    I then adjusted the actual url to the little preview icon that was showing correctly and that seemed to do the trick.

    I’m no expert so any suggestions would be awesome.

    Again thanks so much for creating this plugin and all the time and effort you put in to help WordPress users.

    Thanks so much,

    Lance

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Image won't appear when using get_avatar() call’ is closed to new replies.