mirror of
https://github.com/mediacms-io/mediacms.git
synced 2024-11-28 11:13:36 +01:00
feat: provide slideshow media for images (#1108)
This commit is contained in:
parent
98adb22205
commit
27d1660192
@ -780,6 +780,26 @@ class Media(models.Model):
|
||||
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
|
||||
|
@ -145,6 +145,7 @@ class SingleMediaSerializer(serializers.ModelSerializer):
|
||||
"ratings_info",
|
||||
"add_subtitle_url",
|
||||
"allow_download",
|
||||
"slideshow_items"
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user