From e42748b9e411550ba4a70287cc006824a7199887 Mon Sep 17 00:00:00 2001 From: Jason Robinson Date: Sun, 3 Sep 2017 00:42:50 +0300 Subject: [PATCH] Add GIF upload possibility --- markdownx/forms.py | 7 +++++-- markdownx/settings.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/markdownx/forms.py b/markdownx/forms.py index f162fd3..d6b2700 100755 --- a/markdownx/forms.py +++ b/markdownx/forms.py @@ -33,6 +33,9 @@ class ImageForm(forms.Form): # processed a text file rather than image. _SVG_TYPE = 'image/svg+xml' + # Skip processing for these types + _SKIP_PROCESS = ('image/gif', _SVG_TYPE) + def save(self, commit=True): """ Saves the uploaded image in the designated location. @@ -56,10 +59,10 @@ def save(self, commit=True): image_extension = content_type.split('/')[-1].upper() image_size = getattr(image, '_size') - if content_type.lower() != self._SVG_TYPE: + if content_type.lower() not in self._SKIP_PROCESS: # Processing the raster graphic image. # Note that vector graphics in SVG format - # do not require additional processing and + # or GIF images do not require additional processing and # may be stored as uploaded. image = self._process_raster(image, image_extension) image_size = image.tell() diff --git a/markdownx/settings.py b/markdownx/settings.py index cbe7a16..41ce18d 100755 --- a/markdownx/settings.py +++ b/markdownx/settings.py @@ -8,7 +8,7 @@ # ------------------------------------------------------------------ FIFTY_MEGABYTES = 50 * 1024 * 1024 -VALID_CONTENT_TYPES = 'image/jpeg', 'image/png', 'image/svg+xml' +VALID_CONTENT_TYPES = 'image/jpeg', 'image/png', 'image/svg+xml', 'image/gif' NINETY_DPI = 90 IM_WIDTH = 500 IM_HEIGHT = 500