This function I was made specially for my theme which is running in this blog. I made function because Gravatar generate random images on each user’s avatar if user not uploaded real image, this function will not work no localhost so please use domain path eg: domain.com/wp-content/themes/mytheme/images/DefaultAvatar.jpg
function getavatar_src($author_idOrEMAIL=0,$size=50){ $author_email =$author_idOrEMAIL; if(is_numeric($author_idOrEMAIL)){ $author_email = get_the_author_meta('email',$author_idOrEMAIL); } $default = get_bloginfo('template_directory')."images/defaultavatar.png"; return "https://www.gravatar.com/avatar/" . md5( strtolower( trim( $author_email ) ) ) . "?d=" . urlencode( $default ) . "&s=" . $size; }