Only allow clickable thumbnails for staging files with a valid image
This commit is contained in:
@@ -6,6 +6,8 @@ from django.core.files.base import File
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.utils.translation import ugettext
|
||||
|
||||
from documents.conf.settings import THUMBNAIL_SIZE
|
||||
|
||||
from mimetype.api import get_icon_file_path, get_error_icon_file_path, \
|
||||
get_mimetype
|
||||
from converter.api import convert, cache_cleanup
|
||||
@@ -134,9 +136,13 @@ class StagingFile(object):
|
||||
else:
|
||||
raise OSError(ugettext(u'Unable to delete staging file: %s') % exc)
|
||||
|
||||
def get_valid_image(self, size=THUMBNAIL_SIZE, transformations=None):
|
||||
return convert(self.filepath, size=size, cleanup_files=False, transformations=transformations)
|
||||
|
||||
def get_image(self, size, transformations):
|
||||
try:
|
||||
return convert(self.filepath, size=size, cleanup_files=False, transformations=transformations)
|
||||
return self.get_valid_image(size=size, transformations=transformations)
|
||||
#return convert(self.filepath, size=size, cleanup_files=False, transformations=transformations)
|
||||
except UnknownFileFormat:
|
||||
mimetype, encoding = get_mimetype(open(self.filepath, 'rb'), self.filepath)
|
||||
return get_icon_file_path(mimetype)
|
||||
|
||||
Reference in New Issue
Block a user