parent
d5e72786fe
commit
0d8a608da0
3 changed files with 8 additions and 2 deletions
@ -1,7 +1,11 @@ |
||||
from easy_thumbnails.files import get_thumbnailer |
||||
from easy_thumbnails.exceptions import InvalidImageFormatError |
||||
|
||||
|
||||
def thumbnail(img, size='420x420'): |
||||
weight, height = size.split('x') |
||||
options = {'size': (int(weight), int(height)), 'background': '#fff'} |
||||
return get_thumbnailer(img).get_thumbnail(options) |
||||
try: |
||||
return get_thumbnailer(img).get_thumbnail(options) |
||||
except (ValueError, InvalidImageFormatError): |
||||
return {'url': ''} |
||||
|
||||
Loading…
Reference in new issue