Reputation: 57
I am working on a Django
project using the wonderful easy-thumbnails
plugin to generate thumbnails for images. I don't like how the thumbnails have the format of:
source.jpg.100x100_q80_crop_upscale.jpg
If my image is named source.jpg
, I'd much rather have something like:
source_thumb.jpg
.
Upon reading the plugin's docs (http://easy-thumbnails.readthedocs.org/en/latest/ref/settings/), I have discovered that there is a setting where I can set a custom THUMBNAIL_NAMER
, which is essentially a function that returns the desired thumbnail string.
My Question:
Where is the proper place to define this function in my project? I want to maintain a logical and clean project structure, and am unsure where to place this function.
Thank you so much for any help :)
Upvotes: 1
Views: 268
Reputation: 99660
THUMBNAIL_NAMER
is a setting, and the default is
THUMBNAIL_NAMER = 'easy_thumbnails.namers.default'
which means, in the easy_thumbnails
packages, a method named default
in namers.py
Source code: https://github.com/SmileyChris/easy-thumbnails/blob/master/easy_thumbnails/namers.py#L7
So, if you wish to override it, in your settings.py
THUMBNAIL_HELPER = '<myapp>.namers.default'
and then have the overriden definition of this method in the package myapp
(any app that is in INSTALLED_APPS
that would make most sense), in namers.py
(well, it could be anything - just an example)
Since it is the thumbnail, if it is thumbnail associated with user's avatar, I would put it in the userprofile app.
Upvotes: 1