[COMPONENTS][Avatar] Make sure dimension values are integers

[CARDS][Note] Fix assumed avatar dimension values
This commit is contained in:
Eliseu Amaro 2021-12-26 22:04:55 +00:00
parent 65a3d738ca
commit 19975b8d8d
Signed by: eliseuamaro
GPG Key ID: 96DA09D4B97BC2D5

View File

@ -116,9 +116,8 @@ class Avatar extends Component
public static function getDimensions(int $actor_id, string $size = 'medium') public static function getDimensions(int $actor_id, string $size = 'medium')
{ {
try { try {
$avatar = self::getAvatar($actor_id); $attachment = self::getAvatar($actor_id)->getAttachment();
$a = $size === 'full' ? $avatar->getAttachment() : $avatar->getAttachmentThumbnail($size); return ['width' => (int) $attachment->getWidth(), 'height' => (int) $attachment->getHeight()];
return ['width' => $a->getWidth(), 'height' => $a->getHeight()];
} catch (NoAvatarException) { } catch (NoAvatarException) {
return ['width' => Common::config('thumbnail', 'small'), 'height' => Common::config('thumbnail', 'small')]; return ['width' => Common::config('thumbnail', 'small'), 'height' => Common::config('thumbnail', 'small')];
} }