Show attachment preview on attachment page.

This commit is contained in:
Jan Böhmer 2019-09-25 14:46:00 +02:00
parent 02b71eeab8
commit d99365f906

View file

@ -11,10 +11,11 @@
<tbody>
{% for attachment in form.attachments %}
<tr>
<td>
<td class="row">
<div class="col-9">
{{ form_widget(attachment) }}
</td>
<td>
</div>
<div class="pl-0 col-3">
{{ delete_btn }}
{% set attach = attachment.vars.value %}
@ -39,6 +40,13 @@
</span>
</h6>
{% endif %}
{% if attach.picture %}
<a href="{{ attach | entityURL('file_view') }}" target="_blank" data-no-ajax>
<img class="img-fluid img-thumbnail" src="{{ attach | entityURL('file_view') }}" alt="{% trans %}attachment.preview.alt{% endtrans %}" />
</a>
{% else %}
<a href="{{ attach | entityURL('file_view') }}" target="_blank" data-no-ajax class="link-external">{% trans %}attachment.view{% endtrans %}</a>
{% endif %}
{% else %}
<br><br>
<h6>
@ -47,7 +55,7 @@
</span>
</h6>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
@ -77,12 +85,12 @@
//Increase the index
newForm = newForm.replace(/__name__/g, index);
newForm = '<td>' + newForm + '</td>';
$newFormRow = $('<tr></tr>').html(newForm);
newForm = '<div class="col-9">' + newForm + '</div>';
$newFormRow = $('<tr></tr>').html("<td class='row'>" + newForm + "</td>");
//Add delete button
$btn = '<td>' + '{{ delete_btn|e('js') }}' + '</td>';
$newFormRow.append($btn);
$btn = '<div class="col-3">' + '{{ delete_btn|e('js') }}' + '</div>';
$('td' ,$newFormRow).append($btn);
$holder.append($newFormRow);