1. Denis Savasteev
  2. django-extended-image-field


Denis Savasteev  committed d52da20

Fixes seria

  • Participants
  • Parent commits d57c870
  • Branches default

Comments (0)

Files changed (1)

File eif/fields.py

View file
  • Ignore whitespace
                 except OSError:
                     self.field.dir_sort = False
-            preview_path = self.get_preview_path(preview['name'], image_name, ext)
+            preview_path = self.get_preview_path(preview['name'], image_name, ext.lower())
             width = preview['width'] if 'width' in preview else \
                 float(image.size[0]) * (preview['height'] / float(image.size[1]))
             height = preview['height'] if 'height' in preview else \
                 float(image.size[1]) * (preview['width'] / float(image.size[0]))
             preview_file = image.resize((int(round(width)), int(round(height))), Image.ANTIALIAS)
-            preview_file.save(out, ext.lstrip('.'))
+            preview_file.save(out, ext.lstrip('.').lower().replace('jpg', 'jpeg'))
             self.storage.save(preview_path, ContentFile(out.getvalue()))
     def delete_previews(self, name):
     height - preview's height. If not set it will calculate from
             width on the basis of proportions
     Set attribute dir_sort to True is you want to sort your previews to folders
-    Set attribute widget_preview to name of preview you want to show
-    If not - uploaded image will be shown in admin widget
+    Set attribute widget_preview to name of preview you want to show in admin widget
+    If widget_preview is not set - uploaded image will be shown in admin widget
     Also you can pass yours own widget as widget arg
-    If you lose dir_sort it will set up to True by default
-    If you lose widget it will set up to ExtendedImageField with base image as shown by default
     attr_class = ExtendedImageFieldFile
-    def __init__(self, previews=None, dir_sort=None, widget=None, widget_preview=None, **kwargs):
+    def __init__(self, previews=None, dir_sort=True, widget=None, widget_preview=None, **kwargs):
         self.previews = previews
         self.dir_sort = dir_sort
         self.widget = widget
-        if self.dir_sort is None:
-            self.dir_sort = True
         if self.widget is None:
             preview = widget_preview or 'self'
             self.widget = ExtendedImageWidget(attrs={'preview': preview})