[UI] Set html img width and height attributes for avatar

This commit is contained in:
2021-12-02 15:36:08 +00:00
parent 92d5f3ec1e
commit 772ec6efcf
3 changed files with 17 additions and 1 deletions

View File

@@ -110,6 +110,16 @@ class Avatar extends Component
}
}
public static function getDimensions(int $actor_id, string $size = 'full')
{
try {
$attachment = self::getAvatar($actor_id)->getAttachment();
return ['width' => $attachment->getWidth(), 'height' => $attachment->getHeight()];
} catch (NoAvatarException) {
return ['width' => Common::config('thumbnail', 'small'), 'height' => Common::config('thumbnail', 'small')];
}
}
/**
* Get the cached avatar file info associated with the given Actor id
*