Misc cleanup

This commit is contained in:
Jeremy Stretch 2025-07-30 13:45:51 -04:00
parent 12701afd74
commit 054cb37b0b
2 changed files with 35 additions and 29 deletions

View File

@ -56,13 +56,8 @@
<div class="card"> <div class="card">
<h2 class="card-header">{% trans "Image" %}</h2> <h2 class="card-header">{% trans "Image" %}</h2>
<div class="card-body"> <div class="card-body">
<a href="{{ object.image.url }}" title="{{ object.description }}"> <a href="{{ object.image.url }}" title="{{ object.name }}">
<img {{ object.html_tag }}
src="{{ object.image.url }}"
height="{{ image.height }}"
width="{{ image.width }}"
alt="{{ object.name }}"
/>
</a> </a>
</div> </div>
</div> </div>

View File

@ -1,35 +1,46 @@
{% extends base_template %} {% extends base_template %}
{% load helpers %}
{% load i18n %} {% load i18n %}
{% load render_table from django_tables2 %} {% load render_table from django_tables2 %}
{% load thumbnail %} {% load thumbnail %}
{% block extra_controls %} {% block extra_controls %}
{% if perms.extras.add_imageattachment %} {% if perms.extras.add_imageattachment %}
<a href="{% url 'extras:imageattachment_add' %}?object_type={{ object|content_type_id }}&object_id={{ object.pk }}" class="btn btn-primary"> {% with viewname=object|viewname:"image-attachments" %}
<span class="mdi mdi-plus-thick" aria-hidden="true"></span> {% trans "Attach an Image" %} <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">
</a> <span class="mdi mdi-plus-thick" aria-hidden="true"></span> {% trans "Attach an Image" %}
</a>
{% endwith %}
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div class="d-flex flex-wrap"> {% if image_attachments %}
{% for object in image_attachments %} <div class="d-flex flex-wrap">
<div class="thumbnail m-2"> {% for object in image_attachments %}
{% thumbnail object.image "200x200" crop="center" as tn %} <div class="thumbnail m-2">
<a href="{{ object.get_absolute_url }}" class="d-block" title="{{ object.description }}"> {% thumbnail object.image "200x200" crop="center" as tn %}
<img <a href="{{ object.get_absolute_url }}" class="d-block" title="{{ object.name }}">
src="{{ tn.url }}" <img
width="{{ tn.width }}" src="{{ tn.url }}"
height="{{ tn.height }}" width="{{ tn.width }}"
class="rounded" height="{{ tn.height }}"
alt="{{ object.name }}" class="rounded"
/> alt="{{ object.description or object.name }}"
</a> />
{% endthumbnail %} </a>
<div class="text-center text-secondary text-truncate fs-5"> {% endthumbnail %}
{{ object }} <div class="text-center text-secondary text-truncate fs-5">
{{ object }}
</div>
</div> </div>
</div> {% endfor %}
{% endfor %} </div>
</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 %} {% endblock %}