diff --git a/components/Avatar/Avatar.php b/components/Avatar/Avatar.php index d830b2047f..1df4e87023 100644 --- a/components/Avatar/Avatar.php +++ b/components/Avatar/Avatar.php @@ -43,6 +43,11 @@ class Avatar extends Component return Event::next; } + /** + * @param mixed $tabs + * + * @throws \App\Util\Exception\ClientException + */ public function onPopulateProfileSettingsTabs(Request $request, &$tabs): bool { // TODO avatar template shouldn't be on settings folder @@ -55,20 +60,6 @@ class Avatar extends Component return Event::next; } - public function onStartTwigPopulateVars(array &$vars): bool - { - if (Common::user() !== null) { - $vars['user_avatar'] = self::getAvatarUrl(); - } - return Event::next; - } - - public function onGetAvatarUrl(int $actor_id, ?string &$url): bool - { - $url = self::getAvatarUrl($actor_id); - return Event::next; - } - public function onAvatarUpdate(int $actor_id): bool { Cache::delete('avatar-' . $actor_id); @@ -98,11 +89,10 @@ class Avatar extends Component /** * Get the cached avatar associated with the given Actor id, or the current user if not given */ - public static function getAvatarUrl(?int $actor_id = null, string $size = 'full'): string + public static function getAvatarUrl(int $actor_id, string $size = 'full'): string { - $actor_id = $actor_id ?: Common::userId(); - return Cache::get("avatar-url-{$actor_id}", function () use ($actor_id) { - return Router::url('avatar', ['actor_id' => $actor_id, 'size' => 'full']); + return Cache::get("avatar-url-{$actor_id}", function () use ($actor_id, $size) { + return Router::url('avatar', ['actor_id' => $actor_id, 'size' => $size]); }); } diff --git a/components/Left/Left.php b/components/Left/Left.php index 8105037178..9e0e4bfc14 100644 --- a/components/Left/Left.php +++ b/components/Left/Left.php @@ -38,6 +38,7 @@ class Left extends Component $vars['user_tags'] = $actor->getSelfTags(); $vars['user_followers'] = $actor->getFollowersCount(); $vars['user_followed'] = $actor->getFollowedCount(); + $vars['user_avatar'] = $actor->getAvatarUrl(); } } catch (Exception $e) { Log::error('Got an exception while populating variables for the left panel: ' . $e); diff --git a/plugins/Directory/templates/directory/actor.html.twig b/plugins/Directory/templates/directory/actor.html.twig index 1cd19c5251..0ce3da2bbb 100644 --- a/plugins/Directory/templates/directory/actor.html.twig +++ b/plugins/Directory/templates/directory/actor.html.twig @@ -1,11 +1,12 @@ -{% set actor_nickname = actor.nickname() %} +{% set actor_nickname = actor.getNickname() %} +{% set actor_avatar = actor.getAvatarUrl() %} {% set actor_tags = actor.getSelfTags() %} {% set actor_bio = actor.getBio() %} {% block body %}
- {{ 'Your account\'s avatar.' | trans }} + {{ 'Your account\'s avatar.' | trans }}
diff --git a/templates/note/view.html.twig b/templates/note/view.html.twig index 0171aef8f3..655d6be85f 100644 --- a/templates/note/view.html.twig +++ b/templates/note/view.html.twig @@ -2,7 +2,7 @@ {% set nickname = note.getActorNickname() %}