Welcome! To use this support forum, please Login or Join Today!

   

Non-Gravatar Author Image?

{name}
Rank

Total Posts: 22

Joined 2011-11-22

PM

 

Is there an alternative method of displaying an author’s photo without sending them to Gravatar? I want to use the “About Author” block on contributed blog posts. Many professional people don’t have Gravatars. Others have silly Gravatars they don’t want to use on their authored posts.

Forgive me if this has been changed in later theme versions, I’m stuck on 3.7.1 because I didn’t implement a child theme at the outset of this site.


Attachments:

https://www.filepicker.io/api/file/oCp33IMUQyWy0X3Iia2c

{name}
RankRankRankRank

Total Posts: 3667

Joined 2011-04-27

PM

 

The display method is defined in the st_author_bio() function (specifically where get_avatar() is called).

That said, WordPress pushes Gravatar pretty hard because it’s so heavily tied to the wordpress.com social sphere.

What I’d do is install ACF and add a field group like so:
http://cl.ly/2k2i3o0G2F1t

Then add a field named “profile_image” to that group like so:
http://cl.ly/1F1f2z0D3g3l

Now your users can upload an image from their profile:
http://cl.ly/2D3U2Q0A1T3G


To display the field in your template, edit custom_functions.php within the st_author_bio() function:

echo '<div id="author-avatar">';
// removed in favor of custom profile_image
// echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'smpl_author_bio_avatar_size', 80 ) );

// add custom profile image
$author_image_id = 'user_'.get_the_author_meta('id');
$profile_image_field = get_field('profile_image', $author_image_id);
if ($profile_image_field) {
    echo '<img src="'.wp_get_attachment_thumb_url( $profile_image_field ).'" alt="author photo"/>';
}
// end add custom profile image

echo '</div><!-- #author-avatar -->';