Thumbnails for images and videos #87

Merged
Anna Sirota merged 28 commits from thumbnails into main 2024-04-25 17:50:58 +02:00
Showing only changes of commit 381daa4177 - Show all commits

View File

@ -203,8 +203,9 @@ class File(CreatedModifiedMixin, TrackChangesMixin, models.Model):
Fall back to the source file, if no thumbnail is stored. Fall back to the source file, if no thumbnail is stored.
Log absence of the thumbnail file instead of exploding somewhere in the templates. Log absence of the thumbnail file instead of exploding somewhere in the templates.
""" """
if not self.is_image and not self.is_video: # We don't (yet?) have thumbnails for anything other than images and videos.
return '' assert self.is_image or self.is_video, f'File pk={self.pk} is neither image nor video'
try: try:
path = self.metadata['thumbnails'][size_key]['path'] path = self.metadata['thumbnails'][size_key]['path']
return self.thumbnail.storage.url(path) return self.thumbnail.storage.url(path)