Advertisement
Guest User

Easy author image patch

a guest
Mar 11th, 2014
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.03 KB | None | 0 0
  1. Index: easy-author-image.php
  2. ===================================================================
  3. --- easy-author-image.php (revision 873643)
  4. +++ easy-author-image.php (working copy)
  5. @@ -180,49 +180,44 @@
  6. // This will replace it.
  7. // FUTURE RELEASE: ALLOW USER TO SET MAX WIDTH HEIGHT VIA DISCUSSION SCREEN
  8.  
  9. - $myavatar = "";
  10. -
  11. - if ( is_numeric($id_or_email) ) {
  12. - $id = (int) $id_or_email;
  13. - $user = get_userdata($id);
  14. - if ( $user )
  15. - $email = $user->user_email;
  16. - } elseif ( is_object($id_or_email) ) {
  17. -
  18. - if ( !empty($id_or_email->user_id) ) {
  19. - $id = (int) $id_or_email->user_id;
  20. - $user = get_userdata($id);
  21. - if ( $user)
  22. - $email = $user->user_email;
  23. - } elseif ( !empty($id_or_email->comment_author_email) ) {
  24. - $email = $id_or_email->comment_author_email;
  25. - }
  26. - } else {
  27. - $email = $id_or_email;
  28. - }
  29. -
  30. - // First see if they're a registered user with email set
  31. - if(!empty($email)) {
  32. - // user exists + has email
  33. - $avatar_user = get_user_by('email', $email);
  34. - // check if author_profile_picture is set
  35. - $url = get_the_author_meta('author_profile_picture', $avatar_user->ID);
  36. -
  37. - if($avatar_user && $url){
  38. -
  39. - // there is a url so user has an author profile picture
  40. - $myavatar = '<img class="avatar avatar-'.$size.' photo" width="64" height="64" src="'.$url.'"/>';
  41. -
  42. - } else {
  43. - // No author_profile_picture set OR user does not belong to blog, so default to Gravatar
  44. - $gravatarUrl = "http://www.gravatar.com/avatar.php?gravatar_id=" . md5($email) . "&size=40";
  45. - $myavatar = "<img src='$gravatarUrl' height='64' width='64' alt=".$email."' />";
  46. - }
  47. - }else{
  48. - $myavatar = "<img alt='' src='{$default}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
  49. - }
  50. -
  51. - return $myavatar;
  52. + $myavatar = "";
  53. +
  54. + if (is_numeric($id_or_email)) {
  55. + $id = (int) $id_or_email;
  56. + $user = get_userdata($id);
  57. + if ($user)
  58. + $email = $user->user_email;
  59. + } elseif (is_object($id_or_email)) {
  60. + if (!empty($id_or_email->user_id)) {
  61. + $id = (int) $id_or_email->user_id;
  62. + $user = get_userdata($id);
  63. + if ($user) {
  64. + $email = $user->user_email;
  65. + }
  66. + } elseif (!empty($id_or_email->comment_author_email)) {
  67. + $email = $id_or_email->comment_author_email;
  68. + }
  69. + } else {
  70. + $email = $id_or_email;
  71. + }
  72. + // First see if they're a registered user with email set
  73. + if (!empty($email)) {
  74. + // user exists + has email
  75. + $avatar_user = get_user_by('email', $email);
  76. + // check if author_profile_picture is set
  77. + $url = get_the_author_meta('author_profile_picture', $avatar_user->ID);
  78. + if ($avatar_user && $url) {
  79. + // there is a url so user has an author profile picture
  80. + $myavatar = '<img class="avatar avatar-' . $size . ' photo" width="' . $size . '" height="' . $size . '" src="' . $url . '" />';
  81. + } else {
  82. + // No author_profile_picture set OR user does not belong to blog, so default to Gravatar
  83. + $gravatarUrl = 'http://www.gravatar.com/avatar.php?gravatar_id=' . md5($email) . '&size=40';
  84. + $myavatar = '<img src="' . $gravatarUrl . '" class="avatar avatar-' . $size . ' gravatar avatar-default" height="' . $size . '" width="' . $size . '" alt="' . $email . '" />';
  85. + }
  86. + } else {
  87. + $myavatar = '<img alt="" src="' . $default . '" class="avatar avatar-' . $size . ' photo avatar-default" height="' . $size . '" width="' . $size . '" />';
  88. + }
  89. + return $myavatar;
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement