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> <tbody>
{% for attachment in form.attachments %} {% for attachment in form.attachments %}
<tr> <tr>
<td> <td class="row">
<div class="col-9">
{{ form_widget(attachment) }} {{ form_widget(attachment) }}
</td> </div>
<td> <div class="pl-0 col-3">
{{ delete_btn }} {{ delete_btn }}
{% set attach = attachment.vars.value %} {% set attach = attachment.vars.value %}
@ -39,6 +40,13 @@
</span> </span>
</h6> </h6>
{% endif %} {% 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 %} {% else %}
<br><br> <br><br>
<h6> <h6>
@ -47,7 +55,7 @@
</span> </span>
</h6> </h6>
{% endif %} {% endif %}
</div>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
@ -77,12 +85,12 @@
//Increase the index //Increase the index
newForm = newForm.replace(/__name__/g, index); newForm = newForm.replace(/__name__/g, index);
newForm = '<td>' + newForm + '</td>'; newForm = '<div class="col-9">' + newForm + '</div>';
$newFormRow = $('<tr></tr>').html(newForm); $newFormRow = $('<tr></tr>').html("<td class='row'>" + newForm + "</td>");
//Add delete button //Add delete button
$btn = '<td>' + '{{ delete_btn|e('js') }}' + '</td>'; $btn = '<div class="col-3">' + '{{ delete_btn|e('js') }}' + '</div>';
$newFormRow.append($btn); $('td' ,$newFormRow).append($btn);
$holder.append($newFormRow); $holder.append($newFormRow);