Show attachment name and filename when hovering over an table picture.

This commit is contained in:
Jan Böhmer 2020-05-27 21:54:08 +02:00
parent 53dd0c4228
commit 19e132c746
2 changed files with 17 additions and 4 deletions

View file

@ -83,12 +83,19 @@ final class AttachmentDataTable implements DataTableTypeInterface
if ($context->isPicture() if ($context->isPicture()
&& ! $context->isExternal() && ! $context->isExternal()
&& $this->attachmentHelper->isFileExisting($context)) { && $this->attachmentHelper->isFileExisting($context)) {
$title = htmlspecialchars($context->getName());
if ($context->getFilename()) {
$title .= ' (' . htmlspecialchars($context->getFilename()) . ')';
}
return sprintf( return sprintf(
'<img alt="%s" src="%s" data-thumbnail="%s" class="%s">', '<img alt="%s" src="%s" data-thumbnail="%s" class="%s" data-title="%s">',
'Part image', 'Part image',
$this->attachmentURLGenerator->getThumbnailURL($context), $this->attachmentURLGenerator->getThumbnailURL($context),
$this->attachmentURLGenerator->getThumbnailURL($context, 'thumbnail_md'), $this->attachmentURLGenerator->getThumbnailURL($context, 'thumbnail_md'),
'img-fluid hoverpic' 'img-fluid hoverpic',
$title
); );
} }

View file

@ -161,12 +161,18 @@ final class PartsDataTable implements DataTableTypeInterface
return ''; return '';
} }
$title = htmlspecialchars($preview_attachment->getName());
if ($preview_attachment->getFilename()) {
$title .= ' (' . htmlspecialchars($preview_attachment->getFilename()) . ')';
}
return sprintf( return sprintf(
'<img alt="%s" src="%s" data-thumbnail="%s" class="%s">', '<img alt="%s" src="%s" data-thumbnail="%s" class="%s" data-title="%s">',
'Part image', 'Part image',
$this->attachmentURLGenerator->getThumbnailURL($preview_attachment), $this->attachmentURLGenerator->getThumbnailURL($preview_attachment),
$this->attachmentURLGenerator->getThumbnailURL($preview_attachment, 'thumbnail_md'), $this->attachmentURLGenerator->getThumbnailURL($preview_attachment, 'thumbnail_md'),
'img-fluid hoverpic' 'img-fluid hoverpic',
$title
); );
}, },
]) ])