forked from GNUsocial/gnu-social
[UI] Set html img width and height attributes for avatar
This commit is contained in:
parent
92d5f3ec1e
commit
772ec6efcf
@ -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
|
||||
*
|
||||
|
@ -250,6 +250,11 @@ class Actor extends Entity
|
||||
return Avatar::getAvatarUrl($this->getId(), $size);
|
||||
}
|
||||
|
||||
public function getAvatarDimensions(string $size = 'full')
|
||||
{
|
||||
return Avatar::getDimensions($this->getId(), $size);
|
||||
}
|
||||
|
||||
public static function getById(int $id): ?self
|
||||
{
|
||||
return Cache::get('actor-id-' . $id, fn () => DB::find('actor', ['id' => $id]));
|
||||
|
@ -1,5 +1,6 @@
|
||||
{% set actor_nickname = actor.getNickname() %}
|
||||
{% set actor_avatar = actor.getAvatarUrl() %}
|
||||
{% set actor_avatar_dimensions = actor.getAvatarDimensions() %}
|
||||
{% set actor_tags = actor.getSelfTags()[1] %} {# Take only the actor_tags, not the circles #}
|
||||
{% set actor_bio = actor.getBio() %}
|
||||
{% set actor_uri = actor.getUri() %}
|
||||
@ -8,7 +9,7 @@
|
||||
<section id='profile-{{ actor.id }}' class='profile' title="{{ actor_nickname }}'s {{ 'profile information.' | trans }}">
|
||||
<a href="{{ actor_uri }}">
|
||||
<div class="profile-info">
|
||||
<img src='{{ actor_avatar }}' class="profile-avatar" alt="{{ actor_nickname }}{{ '\'s avatar.' | trans }}">
|
||||
<img src="{{ actor_avatar }}" class="profile-avatar" alt="{% trans %} %actor_nickname%'s avatar. {% endtrans %}" width="{{actor_avatar_dimensions['width']}}" height="{{actor_avatar_dimensions['height']}}">
|
||||
<strong class="profile-info-nickname" title="{{ actor_nickname }}{{ '\'s nickname.' | trans }}">{{ actor_nickname }}</strong>
|
||||
|
||||
<section class="profile-info-bio">
|
||||
|
Loading…
Reference in New Issue
Block a user