Martins Grunskis avatar Martins Grunskis committed b6253ad

fix thumbnail creation with sorl-thumbnail

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: 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/
 

form_utils/widgets.py

 from form_utils.settings import JQUERY_URL
 
 try:
-    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:
     try:
         from easy_thumbnails.files import get_thumbnailer
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.