netbox/netbox/templates/extras/object_imageattachments.html
Jeremy Stretch 9a2fab1d48
Closes #19591: Establish dedicated tab for image attachments (#19919)
* Initial work on #19591

* Ignore images cache directory

* Clean up thumbnails layout

* Include "add attachment" button

* Clean up ObjectImageAttachmentsView

* Add html_tag property to ImageAttachment

* Misc cleanup

* Collapse .gitignore files for /media

* Fix conditional in template
2025-07-31 16:22:04 -04:00

47 lines
1.6 KiB
HTML

{% extends base_template %}
{% load helpers %}
{% load i18n %}
{% load render_table from django_tables2 %}
{% load thumbnail %}
{% block extra_controls %}
{% if perms.extras.add_imageattachment %}
{% with viewname=object|viewname:"image-attachments" %}
<a href="{% url 'extras:imageattachment_add' %}?object_type={{ object|content_type_id }}&object_id={{ object.pk }}&return_url={% url viewname pk=object.pk %}" class="btn btn-primary">
<span class="mdi mdi-plus-thick" aria-hidden="true"></span> {% trans "Attach an Image" %}
</a>
{% endwith %}
{% endif %}
{% endblock %}
{% block content %}
{% if image_attachments %}
<div class="d-flex flex-wrap">
{% for object in image_attachments %}
<div class="thumbnail m-2">
{% thumbnail object.image "200x200" crop="center" as tn %}
<a href="{{ object.get_absolute_url }}" class="d-block" title="{{ object.name }}">
<img
src="{{ tn.url }}"
width="{{ tn.width }}"
height="{{ tn.height }}"
class="rounded"
alt="{{ object.description|default:object.name }}"
/>
</a>
{% endthumbnail %}
<div class="text-center text-secondary text-truncate fs-5">
{{ object }}
</div>
</div>
{% endfor %}
</div>
{% else %}
<div class="alert alert-info">
{% blocktrans with object_type=object|meta:"verbose_name" %}
No images have been attached to this {{ object_type }}.
{% endblocktrans %}
</div>
{% endif %}
{% endblock %}