Refactor get_thumbnail_url
parent
e7884e417e
commit
c40cb86dbd
|
@ -68,7 +68,7 @@ def psd_image_factory(data, *args):
|
||||||
Image.register_open("PSD", psd_image_factory)
|
Image.register_open("PSD", psd_image_factory)
|
||||||
|
|
||||||
|
|
||||||
def get_thumbnail_url(file_obj, thumbnailer_size):
|
def get_thumbnail(file_obj, thumbnailer_size):
|
||||||
# Ugly hack to temporary ignore tiff files
|
# Ugly hack to temporary ignore tiff files
|
||||||
relative_name = file_obj
|
relative_name = file_obj
|
||||||
if isinstance(file_obj, FieldFile):
|
if isinstance(file_obj, FieldFile):
|
||||||
|
@ -79,9 +79,18 @@ def get_thumbnail_url(file_obj, thumbnailer_size):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
path_url = get_thumbnailer(file_obj)[thumbnailer_size].url
|
thumbnailer = get_thumbnailer(file_obj)
|
||||||
thumb_url = get_absolute_url(path_url)
|
return thumbnailer[thumbnailer_size]
|
||||||
except InvalidImageFormatError:
|
except InvalidImageFormatError:
|
||||||
thumb_url = None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def get_thumbnail_url(file_obj, thumbnailer_size):
|
||||||
|
thumbnail = get_thumbnail(file_obj, thumbnailer_size)
|
||||||
|
|
||||||
|
if not thumbnail:
|
||||||
|
return None
|
||||||
|
|
||||||
|
path_url = thumbnail.url
|
||||||
|
thumb_url = get_absolute_url(path_url)
|
||||||
return thumb_url
|
return thumb_url
|
||||||
|
|
Loading…
Reference in New Issue