[PLUGIN][ImageEncoder] Only show thumbnails if they exist

This commit is contained in:
Diogo Peralta Cordeiro 2021-12-26 22:00:58 +00:00
parent 58715f1733
commit ce23660dba
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
2 changed files with 5 additions and 1 deletions

View File

@ -185,11 +185,16 @@ class ImageEncoder extends Plugin
return Event::next;
}
if (\is_null($thumbnail = $vars['attachment']->getThumbnail())) {
return Event::next;
}
$res[] = Formatting::twigRenderFile(
'imageEncoder/imageEncoderView.html.twig',
[
'attachment' => $vars['attachment'],
'note' => $vars['note'],
'thumbnail' => $thumbnail,
],
);
return Event::stop;

View File

@ -1,5 +1,4 @@
<figure>
{% set thumbnail = attachment.getThumbnail() %}
<img class="u-photo"
alt="{{ attachment.getBestTitle(note) }}"
src="{{ attachment.getThumbnailUrl() }}"