From a312eea3a7aac3800e7ea17bdd301ada7b496706 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 24 Feb 2010 20:50:40 +0000 Subject: [PATCH] Hash to static gravatar domains. Props apokalyptik. git-svn-id: http://svn.automattic.com/wordpress/trunk@13385 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/pluggable.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 6da34fdb6e..8aef8283f1 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -1607,10 +1607,17 @@ function get_avatar( $id_or_email, $size = '96', $default = '', $alt = false ) { $default = $avatar_default; } - if ( is_ssl() ) + if ( !empty($email) ) + $email_hash = md5( strtolower( $email ) ); + + if ( is_ssl() ) { $host = 'https://secure.gravatar.com'; - else - $host = 'http://www.gravatar.com'; + } else { + if ( !empty($email) ) + $host = sprintf( "http://w%d.gravatar.com", ( hexdec( $email_hash{0} ) % 2 ) ); + else + $host = 'http://www.gravatar.com'; + } if ( 'mystery' == $default ) $default = "$host/avatar/ad516503a11cd5ca435acc9bb6523536?s={$size}"; // ad516503a11cd5ca435acc9bb6523536 == md5('unknown@gravatar.com') @@ -1627,7 +1634,7 @@ function get_avatar( $id_or_email, $size = '96', $default = '', $alt = false ) { if ( !empty($email) ) { $out = "$host/avatar/"; - $out .= md5( strtolower( $email ) ); + $out .= $email_hash; $out .= '?s='.$size; $out .= '&d=' . urlencode( $default );