mirror of
https://github.com/jazzband/django-avatar.git
synced 2026-03-16 22:20:30 +00:00
AVATAR_DEFAULT_URL can start with http:// if for some reason it's hosted on another domain
Signed-off-by: Jannis Leidel <jannis@leidel.info>
This commit is contained in:
parent
3be0c2ca01
commit
61879cee7e
1 changed files with 4 additions and 1 deletions
|
|
@ -8,6 +8,9 @@ def get_default_avatar_url():
|
|||
base_url = getattr(settings, 'STATIC_URL', None)
|
||||
if not base_url:
|
||||
base_url = getattr(settings, 'MEDIA_URL', '')
|
||||
# Don't use base_url if the default avatar url starts with http://
|
||||
if AVATAR_DEFAULT_URL.startswith('http://'):
|
||||
return AVATAR_DEFAULT_URL
|
||||
# We'll be nice and make sure there are no duplicated forward slashes
|
||||
ends = base_url.endswith('/')
|
||||
begins = AVATAR_DEFAULT_URL.startswith('/')
|
||||
|
|
@ -34,4 +37,4 @@ def get_primary_avatar(user, size=80):
|
|||
if avatar:
|
||||
if not avatar.thumbnail_exists(size):
|
||||
avatar.create_thumbnail(size)
|
||||
return avatar
|
||||
return avatar
|
||||
|
|
|
|||
Loading…
Reference in a new issue