mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Make small user pictures hoverable to show larger version of profile picture.
This commit is contained in:
parent
0063d360ce
commit
04c6d582f2
3 changed files with 24 additions and 2 deletions
|
@ -234,8 +234,9 @@ class LogDataTable implements DataTableTypeInterface
|
|||
$img_url = $this->userAvatarHelper->getAvatarSmURL($user);
|
||||
|
||||
return sprintf(
|
||||
'<img src="%s" class="rounded" style="height: 1.2rem;"> <a href="%s">%s</a>',
|
||||
'<img src="%s" data-thumbnail="%s" class="rounded" style="height: 1.2rem;" data-controller="elements--hoverpic"> <a href="%s">%s</a>',
|
||||
$img_url,
|
||||
$this->userAvatarHelper->getAvatarMdURL($user),
|
||||
$this->urlGenerator->generate('user_info', ['id' => $user->getID()]),
|
||||
htmlentities($user->getFullName(true))
|
||||
);
|
||||
|
|
|
@ -94,6 +94,27 @@ class UserAvatarHelper
|
|||
}
|
||||
}
|
||||
|
||||
public function getAvatarMdURL(User $user): string
|
||||
{
|
||||
//Check if the user has a master attachment defined (meaning he has explicitly defined a profile picture)
|
||||
if ($user->getMasterPictureAttachment() !== null) {
|
||||
return $this->attachmentURLGenerator->getThumbnailURL($user->getMasterPictureAttachment(), 'thumbnail_sm');
|
||||
}
|
||||
|
||||
//If not check if gravatar is enabled (then use gravatar URL)
|
||||
if ($this->use_gravatar) {
|
||||
return $this->getGravatar($user, 150);
|
||||
}
|
||||
|
||||
try {
|
||||
//Otherwise we can serve the relative path via Asset component
|
||||
return $this->filterService->getUrlOfFilteredImage('/img/default_avatar.png', 'thumbnail_xs');
|
||||
} catch (\Imagine\Exception\RuntimeException $e) {
|
||||
//If the filter fails, we can not serve the thumbnail and fall back to the original image and log an warning
|
||||
return $this->packages->getUrl('/img/default_avatar.png');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get either a Gravatar URL or complete image tag for a specified email address.
|
||||
|
|
|
@ -169,7 +169,7 @@
|
|||
{% endmacro %}
|
||||
|
||||
{% macro user_icon(user) %}
|
||||
<img src="{{ avatar_helper.avatarSmURL(user) }}" class="rounded" style="height: 1.2rem;" alt="User avatar">
|
||||
<img src="{{ avatar_helper.avatarSmURL(user) }}" class="rounded" style="height: 1.2rem;" alt="User avatar" {{ stimulus_controller('elements/hoverpic') }} data-thumbnail="{{ avatar_helper.avatarMdURL(user) }}">
|
||||
{% endmacro %}
|
||||
|
||||
{% macro parameters_table(parameters) %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue