1. Carl Meyer
  2. django-form-utils


Martins Grunskis  committed b6253ad

fix thumbnail creation with sorl-thumbnail

  • Participants
  • Parent commits 20bdff3
  • Branches default

Comments (0)

Files changed (2)

File README.rst

View file
  • Ignore whitespace
 `ClearableFileField`_ requires `Django`_ 1.1 or later. 
 `ImageWidget`_ requires the `Python Imaging Library`_.
-`sorl-thumbnail`_ is optional, but without it full-size images will be
-displayed instead of thumbnails.
+`sorl-thumbnail`_ or `easy-thumbnails`_ is optional, but without it
+full-size images will be displayed instead of thumbnails. The default
+thumbnail size is 200px x 200px.
 `AutoResizeTextarea`_ requires `jQuery`_ (by default using a
 Google-served version; see `JQUERY_URL`_).
 .. _Django: http://www.djangoproject.com/
 .. _Python: http://www.python.org/
 .. _sorl-thumbnail: http://pypi.python.org/pypi/sorl-thumbnail
+.. _easy-thumbnails: http://pypi.python.org/pypi/easy-thumbnails
 .. _Python Imaging Library: http://www.pythonware.com/products/pil/
 .. _jQuery: http://www.jquery.com/

File form_utils/widgets.py

View file
  • Ignore whitespace
 from form_utils.settings import JQUERY_URL
-    from sorl.thumbnail.main import DjangoThumbnail
+    from sorl.thumbnail import get_thumbnail
     def thumbnail(image_path, width, height):
-        t = DjangoThumbnail(relative_source=image_path, requested_size=(width,height))
-        return u'<img src="%s" alt="%s" />' % (t.absolute_url, image_path)
+        geometry_string = 'x'.join([str(width), str(height)])
+        t = get_thumbnail(image_path, geometry_string)
+        return u'<img src="%s" alt="%s" />' % (t.url, image_path)
 except ImportError:
         from easy_thumbnails.files import get_thumbnailer