Skip to content

Commit

Permalink
feat: provide slideshow media for images (#1108)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgogoulos authored Nov 14, 2024
1 parent 98adb22 commit 27d1660
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions files/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,26 @@ def poster_url(self):
return helpers.url_from_path(self.poster.path)
return None


@property
def slideshow_items(self):
if self.media_type != "image":
items = []
else:
qs = Media.objects.filter(listable=True, user=self.user, media_type="image").exclude(id=self.id).order_by('id')[:20]

items = [
{
"poster_url": item.poster_url,
"url": item.get_absolute_url(),
"thumbnail_url": item.thumbnail_url,
"title": item.title,
} for item in qs
]

return items


@property
def subtitles_info(self):
"""Property used on serializers
Expand Down
1 change: 1 addition & 0 deletions files/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class Meta:
"ratings_info",
"add_subtitle_url",
"allow_download",
"slideshow_items"
)


Expand Down

0 comments on commit 27d1660

Please sign in to comment.