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">
<h2 class="card-header">{% trans "Image" %}</h2>
<div class="card-body">
<a href="{{ object.image.url }}" title="{{ object.description }}">
<img
src="{{ object.image.url }}"
height="{{ image.height }}"
width="{{ image.width }}"
alt="{{ object.name }}"
/>
<a href="{{ object.image.url }}" title="{{ object.name }}">
{{ object.html_tag }}
</a>
</div>
</div>

View File

@ -1,28 +1,32 @@
{% extends base_template %}
{% load helpers %}
{% load i18n %}
{% load render_table from django_tables2 %}
{% load thumbnail %}
{% block extra_controls %}
{% 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" %}
<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.description }}">
<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.name }}"
alt="{{ object.description or object.name }}"
/>
</a>
{% endthumbnail %}
@ -32,4 +36,11 @@
</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 %}