adds image preview on image attachment #12627

This commit is contained in:
Abhimanyu Saharan 2023-05-25 23:45:04 +05:30
parent bf1c191b2e
commit da9c5572bf

View File

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