[UI][Attachment] Use Attachment methods to get the proper URL, rather than crafting it in a template

This commit is contained in:
2021-08-18 14:04:17 +01:00
parent 9c533a54a7
commit 7320c6834f
5 changed files with 17 additions and 11 deletions

View File

@@ -143,9 +143,9 @@ class ImageEncoder extends Plugin
public function onViewAttachmentImage(array $vars, array &$res): bool
{
$res[] = Formatting::twigRenderFile('imageEncoder/imageEncoderView.html.twig',
['attachment' => $vars['attachment'],
'thumbnail_parameters' => $vars['thumbnail_parameters'],
'note' => $vars['note'],
[
'attachment' => $vars['attachment'],
'note' => $vars['note'],
]);
return Event::stop;
}

View File

@@ -1,6 +1,7 @@
<figure>
<img class="u-photo" src="{{ path('attachment_thumbnail', thumbnail_parameters) }}"
alt="{{ attachment.getFilename() }}">
<img class="u-photo"
alt="{{ attachment.getBestTitle(note) }}"
src="{{ attachment.getThumbnailUrl() }}">
<figcaption><a
href="{{ path('attachment_show', {'id': attachment.getId()}) }}">{{ attachment.getBestTitle(note) }}</a>
</figcaption>