3 * Retrieve user avatar by nickname action class.
9 * @author Evan Prodromou <evan@status.net>
10 * @author Robin Millette <millette@status.net>
11 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
12 * @link http://status.net/
14 * StatusNet - the distributed open-source microblogging tool
15 * Copyright (C) 2008, 2009, StatusNet, Inc.
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU Affero General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU Affero General Public License for more details.
27 * You should have received a copy of the GNU Affero General Public License
28 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 if (!defined('GNUSOCIAL')) { exit(1); }
34 * Retrieve user avatar by nickname action class.
38 * @author Evan Prodromou <evan@status.net>
39 * @author Robin Millette <millette@status.net>
40 * @author Mikael Nordfeldth <mmn@hethane.se>
41 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
42 * @link http://www.gnu.org/software/social/
44 class AvatarbynicknameAction extends Action
49 * @param array $args query arguments
51 * @return boolean false if nickname or user isn't found
53 protected function handle()
56 $nickname = $this->trimmed('nickname');
58 // TRANS: Client error displayed trying to get an avatar without providing a nickname.
59 $this->clientError(_('No nickname.'));
61 $size = $this->trimmed('size') ?: 'original';
63 $user = User::getKV('nickname', $nickname);
65 // TRANS: Client error displayed trying to get an avatar for a non-existing user.
66 $this->clientError(_('No such user.'));
68 $profile = $user->getProfile();
70 // TRANS: Error message displayed when referring to a user without a profile.
71 $this->clientError(_('User has no profile.'));
74 if ($size === 'original') {
76 $avatar = Avatar::getUploaded($profile);
77 $url = $avatar->displayUrl();
78 } catch (NoAvatarException $e) {
79 $url = Avatar::defaultImage(AVATAR_PROFILE_SIZE);
82 $url = $profile->avatarUrl($size);
85 common_redirect($url, 302);
88 function isReadOnly($args)