如何在sorl缩略图3.2.5版本中的python代码中获取缩略图?
sorl缩略图的文档仍然引用了get_thumbnail
函数,但这在v.3.2.5中不存在。 (cannot import name get_thumbnail
)
对于我的一生,我找不到任何关于此函数更改的参考,或者如何在此版本的 sorl 的 python 代码中生成缩略图。有什么建议吗?
The documentation of sorl thumbnail still refers to the get_thumbnail
function, but this doesn't exist in v.3.2.5. (cannot import name get_thumbnail
)
For the life of me, I can't find any reference to what this function was changed to, or how to generate a thumbnail in the python code of this version of sorl. Any advice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在我的特定情况下,我使用了定义了
extra_thumbnails
的 ThumbnailField:image
字段将包含由extra_thumbnails
定义的图像字典选项作为属性,令人惊讶地命名为extra_thumbails
:In my particular case, I've used an ThumbnailField with
extra_thumbnails
defined:The
image
field will have a dict of the images defined by theextra_thumbnails
option as an attribute named, surprisingly,extra_thumbails
:好吧,几周前我发现我之前实际上已经解决了这个问题,我什至写了一篇简短的博客文章 不记得了,- 拍了一下头。如果它只是您想要的 URL,您可以这样做:
这有点 hackish,但它比 Chris 的解决方案更好,因为您可以调用任何缩略图大小,而不需要调整
extra_thumbnails
场地。话虽这么说,我确实发现他的解决方案更干净,因为不需要从 sorl 进行内部导入,但两种方法都应该有效。Well, a few weeks ago I discovered I actually solved this problem before and I even wrote a short blog post about it without remembering, - smacks head. If it's only the URL you're after, you can do this:
It's a bit hackish, but it's better than Chris's solution in the sense that you can call any thumbnail size, without needing to adapt the
extra_thumbnails
field. That being said, I do find his solution cleaner in the sense that there are no internal imports from sorl required, but both ways should work.