Skip to content

Commit

Permalink
Workaround to prevent thumbnail creation for GIFs
Browse files Browse the repository at this point in the history
  • Loading branch information
wfehr committed Oct 22, 2018
1 parent d3eb3d7 commit 21d500a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions easy_thumbnails/conf.py
Expand Up @@ -186,6 +186,11 @@ class Settings(AppSettings):
Instead of a tuple, you can also set this to ``True`` in order to always
preserve the original extension.
"""
THUMBNAIL_PREVENT_GIF_CONVERT = False
"""
Prevent thumbnail creation for GIFs. Created thumbnails for GIFs have no
preserved animations, set to ``True`` if you want to keep them.
"""
THUMBNAIL_TRANSPARENCY_EXTENSION = 'png'
"""
The type of image to save thumbnails with a transparency layer (e.g. GIFs
Expand Down
5 changes: 4 additions & 1 deletion easy_thumbnails/templatetags/thumbnail.py
Expand Up @@ -113,7 +113,10 @@ def render(self, context):
return self.bail_out(context)

try:
thumbnail = get_thumbnailer(source).get_thumbnail(opts)
if settings.THUMBNAIL_PREVENT_GIF_CONVERT and '.gif' in source.url:
thumbnail = source
else:
thumbnail = get_thumbnailer(source).get_thumbnail(opts)
except Exception:
if raise_errors:
raise
Expand Down

0 comments on commit 21d500a

Please sign in to comment.