mirror of
https://github.com/jazzband/django-avatar.git
synced 2026-03-16 22:20:30 +00:00
Added GRAVITAR_FORCEDEFAULT setting
This commit is contained in:
parent
c6e7cbf4a8
commit
d974f45cab
3 changed files with 8 additions and 0 deletions
|
|
@ -13,6 +13,7 @@ class AvatarConf(AppConf):
|
|||
GRAVATAR_FIELD = 'email'
|
||||
GRAVATAR_BACKUP = True
|
||||
GRAVATAR_DEFAULT = None
|
||||
AVATAR_GRAVATAR_FORCEDEFAULT = False
|
||||
DEFAULT_URL = 'avatar/img/default.jpg'
|
||||
MAX_AVATARS_PER_USER = 42
|
||||
MAX_SIZE = 1024 * 1024
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ def avatar_url(user, size=settings.AVATAR_DEFAULT_SIZE):
|
|||
params = {'s': str(size)}
|
||||
if settings.AVATAR_GRAVATAR_DEFAULT:
|
||||
params['d'] = settings.AVATAR_GRAVATAR_DEFAULT
|
||||
if settings.AVATAR_GRAVATAR_FORCEDEFAULT:
|
||||
params['f'] = 'y'
|
||||
path = "%s/?%s" % (hashlib.md5(force_bytes(getattr(user,
|
||||
settings.AVATAR_GRAVATAR_FIELD))).hexdigest(), urlencode(params))
|
||||
return urljoin(settings.AVATAR_GRAVATAR_BASE_URL, path)
|
||||
|
|
|
|||
|
|
@ -139,6 +139,11 @@ AVATAR_GRAVATAR_DEFAULT
|
|||
`Gravatar documentation <https://en.gravatar.com/site/implement/images/#default-image>`_.
|
||||
Defaults to ``None``.
|
||||
|
||||
AVATAR_GRAVATAR_FORCEDEFAULT
|
||||
A bool indicating whether or not to always use the default Gravitar. More details can be found
|
||||
in the `Gravatar documentation <https://en.gravatar.com/site/implement/images/#force-default>`_.
|
||||
Defaults to ``False``.
|
||||
|
||||
AVATAR_GRAVATAR_FIELD
|
||||
The name of the user's field containing the gravatar email. For example, if you set
|
||||
this to ``gravatar`` then django-avatar will get the user's gravatar in ``user.gravatar``.
|
||||
|
|
|
|||
Loading…
Reference in a new issue