Add cache and optimize code
This commit is contained in:
parent
2390968029
commit
473df39cbe
6 changed files with 114 additions and 54 deletions
|
@ -1,5 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load image_tags %}
|
||||
|
||||
<!-- Title -->
|
||||
{% block title %} Albums {% endblock %}
|
||||
|
@ -29,13 +30,16 @@
|
|||
<!-- Album cover image -->
|
||||
<div class="uk-card-media-top">
|
||||
<a href="{{ album.get_absolute_url }}">
|
||||
<img src="{{ album.cover_image_data.url }}"
|
||||
width="{{ album.cover_image_data.width }}"
|
||||
height="{{ album.cover_image_data.height }}"
|
||||
style="aspect-ratio: {{ album.cover_image_data.aspect_ratio }};"
|
||||
{% with album|cover_image_data as img %}
|
||||
<img
|
||||
src="{{ img.url }}"
|
||||
width="{{ img.width }}"
|
||||
height="{{ img.height }}"
|
||||
style="aspect-ratio: {{ img.aspect_ratio }};"
|
||||
alt="Cover image for {{ album.name }}"
|
||||
title="{{ album.name }}"
|
||||
loading="lazy">
|
||||
{% endwith %}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load image_tags %}
|
||||
|
||||
<!-- Title -->
|
||||
{% block title %} Search {% endblock %}
|
||||
|
@ -21,6 +22,7 @@
|
|||
</div>
|
||||
|
||||
<div class="uk-grid-small uk-child-width-1-2@s uk-child-width-1-3@m" uk-grid="masonry: true">
|
||||
|
||||
{% if results %}
|
||||
{% for album in results %}
|
||||
<div>
|
||||
|
@ -29,13 +31,16 @@
|
|||
<!-- Album cover image -->
|
||||
<div class="uk-card-media-top">
|
||||
<a href="{{ album.get_absolute_url }}">
|
||||
<img src="{{ album.cover_image_data.url }}"
|
||||
width="{{ album.cover_image_data.width }}"
|
||||
height="{{ album.cover_image_data.height }}"
|
||||
style="aspect-ratio: {{ album.cover_image_data.aspect_ratio }};"
|
||||
{% with album|cover_image_data as img %}
|
||||
<img
|
||||
src="{{ img.url }}"
|
||||
width="{{ img.width }}"
|
||||
height="{{ img.height }}"
|
||||
style="aspect-ratio: {{ img.aspect_ratio }};"
|
||||
alt="Cover image for {{ album.name }}"
|
||||
title="{{ album.name }}"
|
||||
loading="lazy">
|
||||
{% endwith %}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
@ -56,6 +61,7 @@
|
|||
{% else %}
|
||||
<p>Not found: "{{ query }}".</p>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
||||
{% include "./partials/pagination.html" %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue