From d99365f906c9ebdeadaf6fece75eb8438ae4f9f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Wed, 25 Sep 2019 14:46:00 +0200 Subject: [PATCH] Show attachment preview on attachment page. --- templates/AdminPages/_attachments.html.twig | 64 ++++++++++++--------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/templates/AdminPages/_attachments.html.twig b/templates/AdminPages/_attachments.html.twig index 46736b5d..6c774ef7 100644 --- a/templates/AdminPages/_attachments.html.twig +++ b/templates/AdminPages/_attachments.html.twig @@ -11,43 +11,51 @@ {% for attachment in form.attachments %} - - {{ form_widget(attachment) }} - - - {{ delete_btn }} + +
+ {{ form_widget(attachment) }} +
+
+ {{ delete_btn }} - {% set attach = attachment.vars.value %} + {% set attach = attachment.vars.value %} - {% if attachment_helper.fileExisting(attach) %} - {% if not attach.external %} -

-
+ {% if attachment_helper.fileExisting(attach) %} + {% if not attach.external %} +

+
{{ attach.filename }} -
- +
+ {{ attachment_helper.humanFileSize(attach) }} -
- {% else %} -

-
+
+ {% else %} +

+
{% trans %}attachment.external{% endtrans %} -
- {% endif %} - {% else %} -

-
+
+ {% endif %} + {% if attach.picture %} + + {% trans %}attachment.preview.alt{% endtrans %} + + {% else %} + {% trans %}attachment.view{% endtrans %} + {% endif %} + {% else %} +

+
{% trans %}attachment.file_not_found{% endtrans %} -
- {% endif %} - + + {% endif %} +
{% endfor %} @@ -77,12 +85,12 @@ //Increase the index newForm = newForm.replace(/__name__/g, index); - newForm = '' + newForm + ''; - $newFormRow = $('').html(newForm); + newForm = '
' + newForm + '
'; + $newFormRow = $('').html("" + newForm + ""); //Add delete button - $btn = '' + '{{ delete_btn|e('js') }}' + ''; - $newFormRow.append($btn); + $btn = '
' + '{{ delete_btn|e('js') }}' + '
'; + $('td' ,$newFormRow).append($btn); $holder.append($newFormRow);