Issue #17 new

ImageWidget - sorl.thumbnail.main not found SOLVED

Dan Abel
created an issue

I was getting an error that sorl.thumbnail.main doesn't exist when using ImageWidget. I updated widgets.py (from line 16) from this:

try:
    from sorl.thumbnail.main import DjangoThumbnail
    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)

to this:

try:
    from sorl.thumbnail import get_thumbnail
    def thumbnail(image_path, width, height):
    dimensions = u'%sx%s' % (width, height)
    thumb = get_thumbnail(image_path, dimensions, crop='center', format='PNG')
        return u'<img src="%s" alt="%s" />' % ( thumb.url, image_path)

And it works for me. Hope this helps.