Adds image preview back on the table (#12739)

* adds image preview on image attachment #12627

* adds bootstrap initialization for hx-trigger=load #12627

---------

Co-authored-by: jeremystretch <jstretch@netboxlabs.com>
This commit is contained in:
Abhimanyu Saharan
2023-05-30 19:11:32 +05:30
committed by GitHub
parent 1f71d3570a
commit 9b9a559e0c
4 changed files with 27 additions and 11 deletions

View File

@@ -22,6 +22,14 @@ __all__ = (
'WebhookTable',
)
IMAGEATTACHMENT_IMAGE = '''
{% if record.image %}
<a class="image-preview" href="{{ record.image.url }}" target="_blank">{{ record }}</a>
{% else %}
&mdash;
{% endif %}
'''
class CustomFieldTable(NetBoxTable):
name = tables.Column(
@@ -96,6 +104,9 @@ class ImageAttachmentTable(NetBoxTable):
parent = tables.Column(
linkify=True
)
image = tables.TemplateColumn(
template_code=IMAGEATTACHMENT_IMAGE,
)
size = tables.Column(
orderable=False,
verbose_name='Size (bytes)'