Commit 712f471f authored by Agate's avatar Agate 💬
Browse files

Fix #1205: Added a new, large thumbnail size for cover images

parent b1ae13ab
......@@ -1223,6 +1223,7 @@ VERSATILEIMAGEFIELD_RENDITION_KEY_SETS = {
"attachment_square": [
("original", "url"),
("medium_square_crop", "crop__200x200"),
("large_square_crop", "crop__600x600"),
],
}
VERSATILEIMAGEFIELD_SETTINGS = {
......
......@@ -267,6 +267,13 @@ class Attachment(models.Model):
proxy_url = reverse("api:v1:attachments-proxy", kwargs={"uuid": self.uuid})
return federation_utils.full_url(proxy_url + "?next=medium_square_crop")
@property
def download_url_large_square_crop(self):
if self.file:
return utils.media_url(self.file.crop["600x600"].url)
proxy_url = reverse("api:v1:attachments-proxy", kwargs={"uuid": self.uuid})
return federation_utils.full_url(proxy_url + "?next=large_square_crop")
class MutationAttachment(models.Model):
"""
......
......@@ -297,6 +297,7 @@ class AttachmentSerializer(serializers.Serializer):
urls["source"] = o.url
urls["original"] = o.download_url_original
urls["medium_square_crop"] = o.download_url_medium_square_crop
urls["large_square_crop"] = o.download_url_large_square_crop
return urls
def create(self, validated_data):
......
......@@ -175,7 +175,7 @@ class AttachmentViewSet(
return r
size = request.GET.get("next", "original").lower()
if size not in ["original", "medium_square_crop"]:
if size not in ["original", "medium_square_crop", "large_square_crop"]:
size = "original"
try:
......
......@@ -200,6 +200,9 @@ def test_attachment_serializer_existing_file(factories, to_api_date):
"medium_square_crop": federation_utils.full_url(
attachment.file.crop["200x200"].url
),
"large_square_crop": federation_utils.full_url(
attachment.file.crop["600x600"].url
),
},
}
......@@ -227,6 +230,9 @@ def test_attachment_serializer_remote_file(factories, to_api_date):
"medium_square_crop": federation_utils.full_url(
proxy_url + "?next=medium_square_crop"
),
"large_square_crop": federation_utils.full_url(
proxy_url + "?next=large_square_crop"
),
},
}
......
Added a new, large thumbnail size for cover images (#1205
\ No newline at end of file
......@@ -6,8 +6,8 @@
<div class="ui six wide column current-track">
<div class="ui basic segment" id="player">
<template v-if="currentTrack">
<img ref="cover" alt="" v-if="currentTrack.cover && currentTrack.cover.urls.original" :src="$store.getters['instance/absoluteUrl'](currentTrack.cover.urls.original)">
<img ref="cover" alt="" v-else-if="currentTrack.album && currentTrack.album.cover && currentTrack.album.cover.urls.original" :src="$store.getters['instance/absoluteUrl'](currentTrack.album.cover.urls.original)">
<img ref="cover" alt="" v-if="currentTrack.cover && currentTrack.cover.urls.large_square_crop" :src="$store.getters['instance/absoluteUrl'](currentTrack.cover.urls.large_square_crop)">
<img ref="cover" alt="" v-else-if="currentTrack.album && currentTrack.album.cover && currentTrack.album.cover.urls.large_square_crop" :src="$store.getters['instance/absoluteUrl'](currentTrack.album.cover.urls.large_square_crop)">
<img class="ui image" alt="" v-else src="../assets/audio/default-cover.png">
<h1 class="ui header">
<div class="content ellipsis">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment