Skip to content

Commit

Permalink
Close #263. Enable GIF support
Browse files Browse the repository at this point in the history
  • Loading branch information
fcurella committed Feb 1, 2016
1 parent cf00d77 commit d7af8e8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions sorl/thumbnail/admin/compat.py
Expand Up @@ -35,6 +35,8 @@ def render(self, name, value, attrs=None):
aux_ext = str(value).split('.')
if aux_ext[len(aux_ext)-1].lower() == 'png':
ext = 'PNG'
if aux_ext[len(aux_ext)-1].lower() == 'gif':
ext = 'GIF'
except:
pass
try:
Expand Down
2 changes: 2 additions & 0 deletions sorl/thumbnail/admin/current.py
Expand Up @@ -30,6 +30,8 @@ def render(self, name, value, attrs=None):
aux_ext = str(value).split('.')
if aux_ext[len(aux_ext) - 1].lower() == 'png':
ext = 'PNG'
elif aux_ext[len(aux_ext) - 1].lower() == 'gif':
ext = 'GIF'
except:
pass
try:
Expand Down
3 changes: 3 additions & 0 deletions sorl/thumbnail/base.py
Expand Up @@ -17,6 +17,7 @@
EXTENSIONS = {
'JPEG': 'jpg',
'PNG': 'png',
'GIF': 'gif',
}


Expand Down Expand Up @@ -54,6 +55,8 @@ def _get_format(self, source):
return 'JPEG'
elif file_extension == '.png':
return 'PNG'
elif file_extension == '.gif':
return 'GIF'
else:
from django.conf import settings

Expand Down
2 changes: 1 addition & 1 deletion sorl/thumbnail/conf/defaults.py
Expand Up @@ -58,7 +58,7 @@
# Thumbnail filename prefix
THUMBNAIL_PREFIX = 'cache/'

# Image format, common formats are: JPEG, PNG
# Image format, common formats are: JPEG, PNG, GIF
# Make sure the backend can handle the format you specify
THUMBNAIL_FORMAT = 'JPEG'

Expand Down
1 change: 1 addition & 0 deletions tests/thumbnail_tests/test_backends.py
Expand Up @@ -59,6 +59,7 @@ def test_with_various_formats(self):
self.assertEqual(self.backend._get_format(FakeFile('foo.jpg')), 'JPEG')
self.assertEqual(self.backend._get_format(FakeFile('foo.jpeg')), 'JPEG')
self.assertEqual(self.backend._get_format(FakeFile('foo.png')), 'PNG')
self.assertEqual(self.backend._get_format(FakeFile('foo.gif')), 'GIF')

def test_double_extension(self):
self.assertEqual(self.backend._get_format(FakeFile('foo.ext.jpg')), 'JPEG')
Expand Down

0 comments on commit d7af8e8

Please sign in to comment.