Generic avatar appear if author doesn’t have gravatar
-
Hi,
I’m developing a website with about 120 authors, each with their own page. As you can imagine a fair few haven’t uploaded gravatar images to their email so at the moment there’s an empty image on their author page. I’d like to set up a statement that says:
if author has gravatar display gravatar
else if author doesn’t have gravatar show generic avatarI’ve copied the code I’m using below. The problem is that the get_avatar function always exists because gravatar.com appears to create a gravatar image using a string of numbers relating to the author email regardless of whether it exists or not (e.g. <img src=”https://www.gravatar.com/avatar/e421fe9c8a99f1812ec6e38a84c27a7f?s=100&d=%23646464&r=G”>)
An example of an author page, w/out an image on, that I’m talking about is here: https://www.climatemediapartnership.org/author/annabel_fuller/
The code is below:
<p> <?php if(isset($_GET['author_name'])) : $curauth = get_userdatabylogin($author_name); else : $curauth = get_userdata(intval($author)); endif; ?> <h2> <?php echo $curauth->display_name; ?></h2> <?php global $authordata, $curauth; $authordata=get_userdata(get_query_var( 'author' )); if(function_exists('get_avatar')) { echo get_avatar( get_the_author_id(), 100, "#646464", $default = '' ); } else { echo '<img src="https://www.climatemediapartnership.org/wp-content/themes/ccmp-style/img/avatar.gif" width="100" height="100" />'; } ?> <p><?php echo $curauth->user_description; ?></p> <div style="clear: both"></div>
Any help would be gratefully received!!
thanks alot,
edd
- The topic ‘Generic avatar appear if author doesn’t have gravatar’ is closed to new replies.