Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: easy-author-image.php
- ===================================================================
- --- easy-author-image.php (revision 873643)
- +++ easy-author-image.php (working copy)
- @@ -180,49 +180,44 @@
- // This will replace it.
- // FUTURE RELEASE: ALLOW USER TO SET MAX WIDTH HEIGHT VIA DISCUSSION SCREEN
- - $myavatar = "";
- -
- - if ( is_numeric($id_or_email) ) {
- - $id = (int) $id_or_email;
- - $user = get_userdata($id);
- - if ( $user )
- - $email = $user->user_email;
- - } elseif ( is_object($id_or_email) ) {
- -
- - if ( !empty($id_or_email->user_id) ) {
- - $id = (int) $id_or_email->user_id;
- - $user = get_userdata($id);
- - if ( $user)
- - $email = $user->user_email;
- - } elseif ( !empty($id_or_email->comment_author_email) ) {
- - $email = $id_or_email->comment_author_email;
- - }
- - } else {
- - $email = $id_or_email;
- - }
- -
- - // First see if they're a registered user with email set
- - if(!empty($email)) {
- - // user exists + has email
- - $avatar_user = get_user_by('email', $email);
- - // check if author_profile_picture is set
- - $url = get_the_author_meta('author_profile_picture', $avatar_user->ID);
- -
- - if($avatar_user && $url){
- -
- - // there is a url so user has an author profile picture
- - $myavatar = '<img class="avatar avatar-'.$size.' photo" width="64" height="64" src="'.$url.'"/>';
- -
- - } else {
- - // No author_profile_picture set OR user does not belong to blog, so default to Gravatar
- - $gravatarUrl = "http://www.gravatar.com/avatar.php?gravatar_id=" . md5($email) . "&size=40";
- - $myavatar = "<img src='$gravatarUrl' height='64' width='64' alt=".$email."' />";
- - }
- - }else{
- - $myavatar = "<img alt='' src='{$default}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
- - }
- -
- - return $myavatar;
- + $myavatar = "";
- +
- + if (is_numeric($id_or_email)) {
- + $id = (int) $id_or_email;
- + $user = get_userdata($id);
- + if ($user)
- + $email = $user->user_email;
- + } elseif (is_object($id_or_email)) {
- + if (!empty($id_or_email->user_id)) {
- + $id = (int) $id_or_email->user_id;
- + $user = get_userdata($id);
- + if ($user) {
- + $email = $user->user_email;
- + }
- + } elseif (!empty($id_or_email->comment_author_email)) {
- + $email = $id_or_email->comment_author_email;
- + }
- + } else {
- + $email = $id_or_email;
- + }
- + // First see if they're a registered user with email set
- + if (!empty($email)) {
- + // user exists + has email
- + $avatar_user = get_user_by('email', $email);
- + // check if author_profile_picture is set
- + $url = get_the_author_meta('author_profile_picture', $avatar_user->ID);
- + if ($avatar_user && $url) {
- + // there is a url so user has an author profile picture
- + $myavatar = '<img class="avatar avatar-' . $size . ' photo" width="' . $size . '" height="' . $size . '" src="' . $url . '" />';
- + } else {
- + // No author_profile_picture set OR user does not belong to blog, so default to Gravatar
- + $gravatarUrl = 'http://www.gravatar.com/avatar.php?gravatar_id=' . md5($email) . '&size=40';
- + $myavatar = '<img src="' . $gravatarUrl . '" class="avatar avatar-' . $size . ' gravatar avatar-default" height="' . $size . '" width="' . $size . '" alt="' . $email . '" />';
- + }
- + } else {
- + $myavatar = '<img alt="" src="' . $default . '" class="avatar avatar-' . $size . ' photo avatar-default" height="' . $size . '" width="' . $size . '" />';
- + }
- + return $myavatar;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement