Commit 8ddf3295 authored by Son Nguyen's avatar Son Nguyen Committed by Gerrit Code Review
Browse files

Merge "Fix the parameters for remote_avatar_url(). Bug 1380433"

parents 91c9e3c3 da977d00
...@@ -2672,23 +2672,28 @@ function anonymous_icon_url($maxwidth=40, $maxheight=40, $email=null) { ...@@ -2672,23 +2672,28 @@ function anonymous_icon_url($maxwidth=40, $maxheight=40, $email=null) {
* If the avatar does not exist, return anonymous avatar * If the avatar does not exist, return anonymous avatar
* *
* @param string $email Email address of the user * @param string $email Email address of the user
* @param object $size Maximum size of the image * @param mixed $size Size of the image
* @returns string $url The remote avatar URL * @returns string $url The remote avatar URL
*/ */
function remote_avatar_url($email, $size) { function remote_avatar_url($email, $size) {
global $THEME; global $THEME;
$s = 100;
$newsize = image_get_new_dimensions($s, $s, $size);
if ($newsize) {
$s = min($newsize['w'], $newsize['h']);
}
// Available sizes of the 'no_userphoto' image: // Available sizes of the 'no_userphoto' image:
$allowedsizes = array(16, 20, 25, 40, 50, 60, 100); $allowedsizes = array(16, 20, 25, 40, 50, 60, 100);
if (!in_array($size, $allowedsizes)) { if (!in_array($s, $allowedsizes)) {
log_warn('remote_avatar_url: size should be in (' . join(', ', $allowedsizes) . ')'); log_warn('remote_avatar_url: size should be in (' . join(', ', $allowedsizes) . ')');
} }
else { else {
$size = 40; $s = 40;
} }
$notfound = $THEME->get_url('images/no_userphoto' . $size . '.png'); $notfound = $THEME->get_url('images/no_userphoto' . $s . '.png');
if (!empty($email) && get_config('remoteavatars')) { if (!empty($email) && get_config('remoteavatars')) {
return remote_avatar($email, $size, $notfound); return remote_avatar($email, $s, $notfound);
} }
return $notfound; return $notfound;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment