moviewyrm/bookwyrm/templates/snippets/book_cover.html

69 lines
2.1 KiB
HTML
Raw Normal View History

2021-04-09 21:57:49 +00:00
{% spaceless %}
{% load i18n %}
{% load static %}
2021-05-24 14:16:09 +00:00
{% load imagekit %}
{% load utilities %}
2021-04-09 21:57:49 +00:00
2021-05-24 14:16:09 +00:00
{% if book.cover %}
<picture class="cover-container {{ cover_class }}">
2021-06-06 19:12:21 +00:00
{% if external_path %}
<img
class="book-cover"
src="{{ book.cover }}"
itemprop="thumbnailUrl"
alt="{{ book.alt_text|default:'' }}"
>
{% else %}
2021-08-04 09:42:18 +00:00
{% if thumbnail_generation_enabled %}
2021-08-03 16:03:34 +00:00
{% if size_mobile %}
<source
media="(max-width: 768px)"
type="image/webp"
2021-08-03 16:03:34 +00:00
srcset="{% get_book_cover_thumbnail book=book size=size_mobile ext='webp' %}"
/>
<source
media="(max-width: 768px)"
type="image/jpg"
2021-08-03 16:03:34 +00:00
srcset="{% get_book_cover_thumbnail book=book size=size_mobile ext='jpg' %}"
/>
{% endif %}
2021-08-03 16:03:34 +00:00
<source
type="image/webp"
srcset="{% get_book_cover_thumbnail book=book size=size ext='webp' %}"
/>
<source
type="image/jpg"
srcset="{% get_book_cover_thumbnail book=book size=size ext='jpg' %}"
/>
2021-06-06 19:12:21 +00:00
{% endif %}
2021-06-06 19:12:21 +00:00
<img
alt="{{ book.alt_text|default:'' }}"
2021-06-06 19:12:21 +00:00
class="book-cover"
itemprop="thumbnailUrl"
src="{% if img_path is None %}{% get_media_prefix %}{% else %}{{ img_path }}{% endif %}{{ book.cover }}"
2021-06-06 19:12:21 +00:00
>
2021-06-06 19:12:21 +00:00
{% endif %}
2021-05-24 14:16:09 +00:00
</picture>
{% endif %}
2021-05-24 14:16:09 +00:00
{% if not book.cover and book.alt_text %}
<figure class="cover-container no-cover {{ cover_class }}">
<img
class="book-cover"
src="{% static "images/no_cover.jpg" %}"
alt="{% trans "No cover" %}"
2021-05-24 14:16:09 +00:00
>
2021-05-24 14:16:33 +00:00
<figcaption class="cover-caption">
<p>{{ book.alt_text }}</p>
</figcaption>
2021-05-24 14:16:09 +00:00
</figure>
{% endif %}
2021-04-09 21:57:49 +00:00
{% endspaceless %}