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?
Asked
Active
Viewed 556 times
2 Answers
2
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'

Aamir Rind
- 38,793
- 23
- 126
- 164
-
I've added an issue around using the alias in the thumbnail filename generation: https://github.com/SmileyChris/easy-thumbnails/issues/375 – James Addison Aug 15 '15 at 07:53
0
you can define your own thumbnail-processor
and put as last line here: http://easy-thumbnails.readthedocs.org/en/latest/ref/settings/#easy_thumbnails.conf.Settings.THUMBNAIL_PROCESSORS
THUMBNAIL_PROCESSORS = (
'easy_thumbnails.processors.colorspace',
'easy_thumbnails.processors.autocrop',
'easy_thumbnails.processors.scale_and_crop',
'easy_thumbnails.processors.filters',
'easy_thumbnails.processors.background',
'yourProject.thumbnail_processors.renaming', #<---- your custom one
)
and your processor file (yourProject/thumbnail_processors.py
) would look like:
def renaming(image, bang=False, **kwargs):
"""
rename the filename here and just return the image
"""
return image
not tested though

Mike Covington
- 2,147
- 1
- 16
- 26

doniyor
- 36,596
- 57
- 175
- 260
-
Thanks for your answer, but i'm not quite sure how to "rename the filename". The image is a PIL object and has no property named filename. – RunLoop Jun 17 '15 at 09:00