在django中使用简单缩略图指定文件名后缀 [英] Specify a filename suffix with easy-thumbnails in django
问题描述
我在django中使用简单的缩略图库来创建缩略图。但是,我无法弄清楚如何覆盖缩略图命名过程。此时,lib将缩略图大小附加到文件名,但是我想指定一个自定义名称,例如_大。请问如何做?
I am using the easy-thumbnails lib in django to create thumbnails. However, I can't figure out how to override the thumbnail naming process. At the moment the lib is appending the thumbnail size to the file name, but I would like to specify a custom name e.g. _large. How can this be done please?
推荐答案
django-easy-thumbnailails
使用默认重命名功能。您可以编写自己的命名功能,并将其设置为库应使用的默认命名功能,如下所述 THUMBNAIL_NAMER :
django-easy-thumbnails
uses default renaming function. You can write your own naming function and set it in settings as a default naming function the library should use, as described here THUMBNAIL_NAMER:
myapp.utils
def namer(thumbnailer, prepared_options, source_filename,
thumbnail_extension, **kwargs):
# do something and return name
pass
settings.py
THUMBNAIL_NAMER = 'myapp.utils.namer'
这篇关于在django中使用简单缩略图指定文件名后缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!