moviewyrm/bookwyrm/templates/snippets/book_cover.html

128 lines
5 KiB
HTML
Raw Normal View History

2021-04-09 21:57:49 +00:00
{% spaceless %}
{% load i18n %}
2021-05-24 14:16:09 +00:00
{% load imagekit %}
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-06-06 19:12:21 +00:00
{% 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 %}
2021-06-06 19:12:21 +00:00
{% 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 %}
2021-06-06 19:12:21 +00:00
<img
class="book-cover"
src="/images/{{ book.cover }}"
itemprop="thumbnailUrl"
alt="{{ book.alt_text|default:'' }}"
>
{% 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 %}