Fix image url in user search
This commit is contained in:
parent
fdbfa01f6b
commit
532137e54c
4 changed files with 21 additions and 59 deletions
|
@ -9,14 +9,14 @@ from . import registry
|
|||
|
||||
|
||||
@registry.function
|
||||
def gravatar(profile, size=80, default=None):
|
||||
assert isinstance(profile, Profile), "profile should be Profile"
|
||||
profile_image = profile.profile_image
|
||||
def gravatar(profile, size=80, default=None, profile_image=None, email=None):
|
||||
if profile_image:
|
||||
return profile_image.url
|
||||
if default is None:
|
||||
return profile_image
|
||||
if profile and profile.profile_image:
|
||||
return profile.profile_image.url
|
||||
if default is None and profile:
|
||||
default = profile.mute
|
||||
email = profile.user.email
|
||||
email = email or profile.user.email
|
||||
gravatar_url = (
|
||||
"//www.gravatar.com/avatar/"
|
||||
+ hashlib.md5(utf8bytes(email.strip().lower())).hexdigest()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue