Martins Grunskis  committed b6253ad

fix thumbnail creation with sorl-thumbnail

  • Participants
  • Parent commits 20bdff3
  • Branches default

Comments (0)

Files changed (2)

 `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:
 .. _Python:
 .. _sorl-thumbnail:
+.. _easy-thumbnails:
 .. _Python Imaging Library:
 .. _jQuery:

File form_utils/

 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