如何在sorl缩略图的3.2.5版中的python代码中获取缩略图?

| sorl缩略图的文档仍然引用
get_thumbnail
函数,但是在v.3.2.5中不存在。 (
cannot import name get_thumbnail
) 为了我的一生,我找不到关于此函数更改内容或如何在此版本的sorl的python代码中生成缩略图的任何参考。有什么建议吗?     
已邀请:
在我的特殊情况下,我使用了定义为
extra_thumbnails
的ThumbnailField:
class SomeModel(models.Model):
    # other kwargs omitted for clarity
    image = ThumbnailField(extra_thumbnails={
                           \'inline_preview\': {\'size\': (600,400)},
                           \'small_thumb\': {\'size\': (75,75), \'options\':[\'crop\', \'sharpen\']})
image
字段将由
extra_thumbnails
选项定义的图像指定为属性dict,
extra_thumbails
somemodel_instance.image.extra_thumbnails[\'inline_preview\']
    
好吧,几个星期前,我发现我实际上已经解决了这个问题,甚至还写了一篇关于它的简短博客文章,而没有记起-打sm。如果仅是您要访问的URL,则可以执行以下操作:
from solr.thumbnail.main import DjangoThumbnail

img = imageObject # a normal image url returned from an ImageField
size = (100,100) # any tuple 
img_resize_url = unicode(DjangoThumbnail(img, size))
它有点怪异,但从某种意义上说,它比Chris的解决方案要好,因为您可以调用任何缩略图大小,而无需适应
extra_thumbnails
字段。话虽这么说,但我的确找到了他的解决方案,因为它不需要内部从sorl导入,但是两种方法都应该起作用。     

要回复问题请先登录注册