Added thumbnail urls to book cover srcsets with cache busting ids

This commit is contained in:
mmonkey
2020-12-24 02:35:32 -06:00
parent 626051e489
commit 242a2767a1
15 changed files with 199 additions and 55 deletions
+1 -1
View File
@@ -36,7 +36,7 @@
<div id="books" class="col-sm-3 col-lg-2 col-xs-6 book">
<div class="cover">
<a href="{{ url_for('web.show_book', book_id=entry.id) }}">
{{ book_cover_image(entry, entry.title) }}
{{ book_cover_image(entry, entry.id|get_book_thumbnails(thumbnails)) }}
</a>
</div>
<div class="meta">
+12 -7
View File
@@ -1,8 +1,13 @@
{% macro book_cover_image(book, book_title) -%}
<img
srcset="{{ url_for('web.get_cached_cover', cache_id=book|book_cover_cache_id(1)) }} 1x,
{{ url_for('web.get_cached_cover', cache_id=book|book_cover_cache_id(2)) }} 2x"
src="{{ url_for('web.get_cached_cover', cache_id=book|book_cover_cache_id) }}"
alt="{{ book_title }}"
/>
{% macro book_cover_image(book, thumbnails) -%}
{%- set book_title = book.title if book.title else book.name -%}
{% set srcset = thumbnails|get_book_thumbnail_srcset if thumbnails|length else '' %}
{%- if srcset|length -%}
<img
srcset="{{ srcset }}"
src="{{ url_for('web.get_cached_cover', cache_id=book|book_cover_cache_id) }}"
alt="{{ book_title }}"
/>
{%- else -%}
<img src="{{ url_for('web.get_cached_cover', cache_id=book|book_cover_cache_id) }}" alt="{{ book_title }}" />
{%- endif -%}
{%- endmacro %}
+1 -1
View File
@@ -4,7 +4,7 @@
{% if book %}
<div class="col-sm-3 col-lg-3 col-xs-12">
<div class="cover">
{{ book_cover_image(book, book.title) }}
{{ book_cover_image(book, book.id|get_book_thumbnails(thumbnails)) }}
</div>
{% if g.user.role_delete_books() %}
<div class="text-center">
+1 -1
View File
@@ -4,7 +4,7 @@
<div class="row">
<div class="col-sm-3 col-lg-3 col-xs-5">
<div class="cover">
{{ book_cover_image(entry, entry.title) }}
{{ book_cover_image(entry, entry.id|get_book_thumbnails(thumbnails)) }}
</div>
</div>
<div class="col-sm-9 col-lg-9 book-meta">
+1 -1
View File
@@ -9,7 +9,7 @@
<div class="cover">
{% if entry.has_cover is defined %}
<a href="{{ url_for('web.show_book', book_id=entry.id) }}" data-toggle="modal" data-target="#bookDetailsModal" data-remote="false">
{{ book_cover_image(entry, entry.title) }}
{{ book_cover_image(entry, entry.id|get_book_thumbnails(thumbnails)) }}
</a>
{% endif %}
</div>
+1 -1
View File
@@ -29,7 +29,7 @@
<div class="col-sm-3 col-lg-2 col-xs-6 book sortable" {% if entry[0].sort %}data-name="{{entry[0].series[0].name}}"{% endif %} data-id="{% if entry[0].series[0].name %}{{entry[0].series[0].name}}{% endif %}">
<div class="cover">
<a href="{{url_for('web.books_list', data=data, sort_param='new', book_id=entry[0].series[0].id )}}">
{{ book_cover_image(entry[0], entry[0].name) }}
{{ book_cover_image(entry[0], entry[0].id|get_book_thumbnails(thumbnails)) }}
<span class="badge">{{entry.count}}</span>
</a>
</div>
+2 -2
View File
@@ -9,7 +9,7 @@
<div class="col-sm-3 col-lg-2 col-xs-6 book" id="books_rand">
<div class="cover">
<a href="{{ url_for('web.show_book', book_id=entry.id) }}" data-toggle="modal" data-target="#bookDetailsModal" data-remote="false">
{{ book_cover_image(entry, entry.title) }}
{{ book_cover_image(entry, entry.id|get_book_thumbnails(thumbnails)) }}
</a>
</div>
<div class="meta">
@@ -83,7 +83,7 @@
<div class="col-sm-3 col-lg-2 col-xs-6 book" id="books">
<div class="cover">
<a href="{{ url_for('web.show_book', book_id=entry.id) }}" data-toggle="modal" data-target="#bookDetailsModal" data-remote="false">
{{ book_cover_image(entry, entry.title) }}
{{ book_cover_image(entry, entry.id|get_book_thumbnails(thumbnails)) }}
</a>
</div>
<div class="meta">
+1 -1
View File
@@ -44,7 +44,7 @@
<div class="cover">
{% if entry.has_cover is defined %}
<a href="{{ url_for('web.show_book', book_id=entry.id) }}" data-toggle="modal" data-target="#bookDetailsModal" data-remote="false">
{{ book_cover_image(entry, entry.title) }}
{{ book_cover_image(entry, entry.id|get_book_thumbnails(thumbnails)) }}
</a>
{% endif %}
</div>
+1 -1
View File
@@ -31,7 +31,7 @@
<div class="col-sm-3 col-lg-2 col-xs-6 book">
<div class="cover">
<a href="{{ url_for('web.show_book', book_id=entry.id) }}" data-toggle="modal" data-target="#bookDetailsModal" data-remote="false">
{{ book_cover_image(entry, entry.title) }}
{{ book_cover_image(entry, entry.id|get_book_thumbnails(thumbnails)) }}
</a>
</div>
<div class="meta">