From ce23660dba29f680d9dd73612b79694095b6c09c Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Sun, 26 Dec 2021 22:00:58 +0000 Subject: [PATCH] [PLUGIN][ImageEncoder] Only show thumbnails if they exist --- plugins/ImageEncoder/ImageEncoder.php | 5 +++++ .../templates/imageEncoder/imageEncoderView.html.twig | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/ImageEncoder/ImageEncoder.php b/plugins/ImageEncoder/ImageEncoder.php index bb96104703..d3eaf2b658 100644 --- a/plugins/ImageEncoder/ImageEncoder.php +++ b/plugins/ImageEncoder/ImageEncoder.php @@ -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; diff --git a/plugins/ImageEncoder/templates/imageEncoder/imageEncoderView.html.twig b/plugins/ImageEncoder/templates/imageEncoder/imageEncoderView.html.twig index 489b14f13c..9922dbc08b 100644 --- a/plugins/ImageEncoder/templates/imageEncoder/imageEncoderView.html.twig +++ b/plugins/ImageEncoder/templates/imageEncoder/imageEncoderView.html.twig @@ -1,5 +1,4 @@
- {% set thumbnail = attachment.getThumbnail() %}