Server should now check local avatar file instead of URL

This commit is contained in:
Josef Citrine 2016-11-12 21:38:03 +00:00
parent 1c40d3cfa5
commit b356cfaea1
2 changed files with 21 additions and 12 deletions

View file

@ -172,18 +172,8 @@ class ArtistsController extends ApiControllerBase
];
}
$formatted_palette = [
"#ffffff",
"#ffffff",
"#ffffff"
];
try {
$palette = ColorThief::getPalette($user->getAvatarUrl(Image::SMALL), 2);
$palette = ColorThief::getPalette($user->getAvatarUrlLocal(Image::SMALL), 2);
$formatted_palette = array_map("Helpers::rgb2hex", $palette);
} catch (Exception $e) {
// We failed to get the image, oh well
}
$followers = Follower::where('artist_id', $user->id)
->count();

View file

@ -273,6 +273,25 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
return Gravatar::getUrl($email, Image::$ImageTypes[$type]['width']);
}
public function getAvatarUrlLocal($type = Image::NORMAL)
{
if (!$this->uses_gravatar && $this->avatar !== null) {
return $this->avatar->getFile($type);
}
if ($this->email == "redacted@example.net") {
return Gravatar::getUrl($this->id."", Image::$ImageTypes[$type]['width'], "identicon");
}
$email = $this->gravatar;
if (!strlen($email)) {
$email = $this->email;
}
return Gravatar::getUrl($email, Image::$ImageTypes[$type]['width']);
}
/**
* Get the token value for the "remember me" session.
*