mirror of
https://github.com/ae-utbm/sith.git
synced 2025-02-26 09:27:09 +00:00
Use real images with lazy loading in sas albums and user pictures
This commit is contained in:
parent
e8db68b960
commit
f7ff77b88f
@ -39,6 +39,8 @@ class PictureSchema(ModelSchema):
|
|||||||
compressed_url: str
|
compressed_url: str
|
||||||
thumb_url: str
|
thumb_url: str
|
||||||
album: str
|
album: str
|
||||||
|
report_url: str
|
||||||
|
edit_url: str
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def resolve_sas_url(obj: Picture) -> str:
|
def resolve_sas_url(obj: Picture) -> str:
|
||||||
@ -56,6 +58,14 @@ class PictureSchema(ModelSchema):
|
|||||||
def resolve_thumb_url(obj: Picture) -> str:
|
def resolve_thumb_url(obj: Picture) -> str:
|
||||||
return obj.get_download_thumb_url()
|
return obj.get_download_thumb_url()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def resolve_report_url(obj: Picture) -> str:
|
||||||
|
return reverse("sas:picture_ask_removal", kwargs={"picture_id": obj.id})
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def resolve_edit_url(obj: Picture) -> str:
|
||||||
|
return reverse("sas:picture_edit", kwargs={"picture_id": obj.id})
|
||||||
|
|
||||||
|
|
||||||
class PictureRelationCreationSchema(Schema):
|
class PictureRelationCreationSchema(Schema):
|
||||||
picture: NonNegativeInt
|
picture: NonNegativeInt
|
||||||
|
@ -166,6 +166,13 @@ main {
|
|||||||
|
|
||||||
border: 1px solid rgba(0, 0, 0, .3);
|
border: 1px solid rgba(0, 0, 0, .3);
|
||||||
|
|
||||||
|
>img {
|
||||||
|
object-position: top bottom;
|
||||||
|
object-fit: contain;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 500px) {
|
@media (max-width: 500px) {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
@ -78,8 +78,8 @@
|
|||||||
<div
|
<div
|
||||||
class="photo"
|
class="photo"
|
||||||
:class="{not_moderated: !picture.is_moderated}"
|
:class="{not_moderated: !picture.is_moderated}"
|
||||||
:style="`background-image: url(${picture.thumb_url})`"
|
|
||||||
>
|
>
|
||||||
|
<img :src="picture.thumb_url" :alt="picture.name" loading="lazy" />
|
||||||
<template x-if="!picture.is_moderated">
|
<template x-if="!picture.is_moderated">
|
||||||
<div class="overlay"> </div>
|
<div class="overlay"> </div>
|
||||||
<div class="text">{% trans %}To be moderated{% endtrans %}</div>
|
<div class="text">{% trans %}To be moderated{% endtrans %}</div>
|
||||||
|
@ -2,15 +2,19 @@
|
|||||||
<a href="{{ url('sas:album', album_id=a.id) }}">
|
<a href="{{ url('sas:album', album_id=a.id) }}">
|
||||||
{% if a.file %}
|
{% if a.file %}
|
||||||
{% set img = a.get_download_url() %}
|
{% set img = a.get_download_url() %}
|
||||||
|
{% set src = a.name %}
|
||||||
{% elif a.children.filter(is_folder=False, is_moderated=True).exists() %}
|
{% elif a.children.filter(is_folder=False, is_moderated=True).exists() %}
|
||||||
{% set img = a.children.filter(is_folder=False).first().as_picture.get_download_thumb_url() %}
|
{% set picture = a.children.filter(is_folder=False).first().as_picture %}
|
||||||
|
{% set img = picture.get_download_thumb_url() %}
|
||||||
|
{% set src = picture.name %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set img = static('core/img/sas.jpg') %}
|
{% set img = static('core/img/sas.jpg') %}
|
||||||
|
{% set src = "sas.jpg" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div
|
<div
|
||||||
class="album{% if not a.is_moderated %} not_moderated{% endif %}"
|
class="album{% if not a.is_moderated %} not_moderated{% endif %}"
|
||||||
style="background-image: url('{{ img }}');"
|
|
||||||
>
|
>
|
||||||
|
<img src="{{ img }}" alt="{{ src }}" loading="lazy" />
|
||||||
{% if not a.is_moderated %}
|
{% if not a.is_moderated %}
|
||||||
<div class="overlay"> </div>
|
<div class="overlay"> </div>
|
||||||
<div class="text">{% trans %}To be moderated{% endtrans %}</div>
|
<div class="text">{% trans %}To be moderated{% endtrans %}</div>
|
||||||
|
@ -114,12 +114,12 @@
|
|||||||
{% trans %}HD version{% endtrans %}
|
{% trans %}HD version{% endtrans %}
|
||||||
</a>
|
</a>
|
||||||
<br>
|
<br>
|
||||||
<a class="text danger" :href="`/sas/picture/${currentPicture.id}/report`">
|
<a class="text danger" :href="currentPicture.report_url">
|
||||||
{% trans %}Ask for removal{% endtrans %}
|
{% trans %}Ask for removal{% endtrans %}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<a class="button" :href="`/sas/picture/${currentPicture.id}/edit/`"><i class="fa-regular fa-pen-to-square edit-action"></i></a>
|
<a class="button" :href="currentPicture.edit_url"><i class="fa-regular fa-pen-to-square edit-action"></i></a>
|
||||||
<a class="button" href="?rotate_left"><i class="fa-solid fa-rotate-left"></i></a>
|
<a class="button" href="?rotate_left"><i class="fa-solid fa-rotate-left"></i></a>
|
||||||
<a class="button" href="?rotate_right"><i class="fa-solid fa-rotate-right"></i></a>
|
<a class="button" href="?rotate_right"><i class="fa-solid fa-rotate-right"></i></a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -35,8 +35,8 @@
|
|||||||
<div
|
<div
|
||||||
class="photo"
|
class="photo"
|
||||||
:class="{not_moderated: !picture.is_moderated}"
|
:class="{not_moderated: !picture.is_moderated}"
|
||||||
:style="`background-image: url(${picture.thumb_url})`"
|
|
||||||
>
|
>
|
||||||
|
<img :src="picture.thumb_url" :alt="picture.name" loading="lazy" />
|
||||||
<template x-if="!picture.is_moderated">
|
<template x-if="!picture.is_moderated">
|
||||||
<div class="overlay"> </div>
|
<div class="overlay"> </div>
|
||||||
<div class="text">{% trans %}To be moderated{% endtrans %}</div>
|
<div class="text">{% trans %}To be moderated{% endtrans %}</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user