Rename gravatar_img() more generic to avatar_img().

I would like to extend the Gravatar support to also use Libravatar, a decentralized avatar service.
First step to extract Gravatar from core and put it into its own plugin. Later the Libravatar plugin can be done, too as a plugin.
This commit is contained in:
Klaus Weidenbach 2012-02-21 00:54:34 +01:00
parent d25a9df996
commit 93ffba58cc
3 changed files with 7 additions and 7 deletions

View File

@ -446,7 +446,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
$phost = substr($url,strpos($url,'@')+1); $phost = substr($url,strpos($url,'@')+1);
$profile = 'http://' . $phost; $profile = 'http://' . $phost;
// fix nick character range // fix nick character range
$vcard = array('fn' => $name, 'nick' => $name, 'photo' => gravatar_img($url)); $vcard = array('fn' => $name, 'nick' => $name, 'photo' => avatar_img($url));
$notify = 'smtp ' . random_string(); $notify = 'smtp ' . random_string();
$poll = 'email ' . random_string(); $poll = 'email ' . random_string();
$priority = 0; $priority = 0;
@ -655,7 +655,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
} }
if((! $vcard['photo']) && strlen($email)) if((! $vcard['photo']) && strlen($email))
$vcard['photo'] = gravatar_img($email); $vcard['photo'] = avatar_img($email);
if($poll === $profile) if($poll === $profile)
$lnk = $feed->get_permalink(); $lnk = $feed->get_permalink();
if(isset($lnk) && strlen($lnk)) if(isset($lnk) && strlen($lnk))

View File

@ -692,13 +692,13 @@ function allowed_email($email) {
}} }}
if(! function_exists('gravatar_img')) { if(! function_exists('avatar_img')) {
function gravatar_img($email) { function avatar_img($email) {
$size = 175; $size = 175;
$opt = 'identicon'; // psuedo-random geometric pattern if not found $opt = 'identicon'; // psuedo-random geometric pattern if not found
$rating = 'pg'; $rating = 'pg';
$hash = md5(trim(strtolower($email))); $hash = md5(trim(strtolower($email)));
$url = 'http://www.gravatar.com/avatar/' . $hash . '.jpg' $url = 'http://www.gravatar.com/avatar/' . $hash . '.jpg'
. '?s=' . $size . '&d=' . $opt . '&r=' . $rating; . '?s=' . $size . '&d=' . $opt . '&r=' . $rating;

View File

@ -324,7 +324,7 @@ function register_post(&$a) {
require_once('include/Photo.php'); require_once('include/Photo.php');
if(($use_gravatar) && (! strlen($photo))) if(($use_gravatar) && (! strlen($photo)))
$photo = gravatar_img($email); $photo = avatar_img($email);
$photo_failure = false; $photo_failure = false;
$filename = basename($photo); $filename = basename($photo);
@ -333,7 +333,7 @@ function register_post(&$a) {
if($img->is_valid()) { if($img->is_valid()) {
$img->scaleImageSquare(175); $img->scaleImageSquare(175);
$hash = photo_new_resource(); $hash = photo_new_resource();
$r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 4 ); $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 4 );