Thumbnails for images and videos #87
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user