moviewyrm/bookwyrm/templates/snippets/book_cover.html
2021-08-02 12:56:11 -07:00

137 lines
5.6 KiB
HTML

{% spaceless %}
{% load i18n %}
{% load static %}
{% load imagekit %}
{% if book.cover %}
<picture class="cover-container {{ cover_class }}">
{% if external_path %}
<img
class="book-cover"
src="{{ book.cover }}"
itemprop="thumbnailUrl"
alt="{{ book.alt_text|default:'' }}"
>
{% else %}
{% if enable_thumbnail_generation %}
{% if size_mobile == 'xsmall' %}
<source
media="(max-width: 768px)"
type="image/webp"
srcset="{{ book.cover_bw_book_xsmall_webp.url }}"
/>
<source
media="(max-width: 768px)"
type="image/jpg"
srcset="{{ book.cover_bw_book_xsmall_jpg.url }}"
/>
{% elif size_mobile == 'small' %}
<source
media="(max-width: 768px)"
type="image/webp"
srcset="{{ book.cover_bw_book_small_webp.url }}"
/>
<source
media="(max-width: 768px)"
type="image/jpg"
srcset="{{ book.cover_bw_book_small_jpg.url }}"
/>
{% elif size_mobile == 'medium' %}
<source
media="(max-width: 768px)"
type="image/webp"
srcset="{{ book.cover_bw_book_medium_webp.url }}"
/>
<source
media="(max-width: 768px)"
type="image/jpg"
srcset="{{ book.cover_bw_book_medium_jpg.url }}"
/>
{% elif size_mobile == 'large' %}
<source
media="(max-width: 768px)"
type="image/webp"
srcset="{{ book.cover_bw_book_large_webp.url }}"
/>
<source
media="(max-width: 768px)"
type="image/jpg"
srcset="{{ book.cover_bw_book_large_jpg.url }}"
/>
{% elif size_mobile == 'xlarge' %}
<source
media="(max-width: 768px)"
type="image/webp"
srcset="{{ book.cover_bw_book_xlarge_webp.url }}"
/>
<source
media="(max-width: 768px)"
type="image/jpg"
srcset="{{ book.cover_bw_book_xlarge_jpg.url }}"
/>
{% elif size_mobile == 'xxlarge' %}
<source
media="(max-width: 768px)"
type="image/webp"
srcset="{{ book.cover_bw_book_xxlarge_webp.url }}"
/>
<source
media="(max-width: 768px)"
type="image/jpg"
srcset="{{ book.cover_bw_book_xxlarge_jpg.url }}"
/>
{% endif %}
{% if size == 'xsmall' %}
<source type="image/webp" srcset="{{ book.cover_bw_book_xsmall_webp.url }}"/>
<source type="image/jpg" srcset="{{ book.cover_bw_book_xsmall_jpg.url }}"/>
{% elif size == 'small' %}
<source type="image/webp" srcset="{{ book.cover_bw_book_small_webp.url }}"/>
<source type="image/jpg" srcset="{{ book.cover_bw_book_small_jpg.url }}"/>
{% elif size == 'medium' %}
<source type="image/webp" srcset="{{ book.cover_bw_book_medium_webp.url }}"/>
<source type="image/jpg" srcset="{{ book.cover_bw_book_medium_jpg.url }}"/>
{% elif size == 'large' %}
<source type="image/webp" srcset="{{ book.cover_bw_book_large_webp.url }}"/>
<source type="image/jpg" srcset="{{ book.cover_bw_book_large_jpg.url }}"/>
{% elif size == 'xlarge' %}
<source type="image/webp" srcset="{{ book.cover_bw_book_xlarge_webp.url }}"/>
<source type="image/jpg" srcset="{{ book.cover_bw_book_xlarge_jpg.url }}"/>
{% elif size == 'xxlarge' %}
<source type="image/webp" srcset="{{ book.cover_bw_book_xxlarge_webp.url }}"/>
<source type="image/jpg" srcset="{{ book.cover_bw_book_xxlarge_jpg.url }}"/>
{% endif %}
{% endif %}
<img
class="book-cover"
itemprop="thumbnailUrl"
{% if book.cover %}
src="{% if img_path is None %}{% get_media_prefix %}{% else %}{{ img_path }}{% endif %}{{ book.cover }}"
{% else %}
src="{% static "images/no_cover.jpg" %}"
alt="{% trans "No cover" %}"
{% endif %}
>
{% endif %}
</picture>
{% endif %}
{% 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" %}"
>
<figcaption class="cover-caption">
<p>{{ book.alt_text }}</p>
</figcaption>
</figure>
{% endif %}
{% endspaceless %}