aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorEthan Koenig <ethantkoenig@gmail.com>2017-06-29 12:10:33 -0400
committerEthan Koenig <ethantkoenig@gmail.com>2017-06-29 12:10:33 -0400
commit05e37264154bbcb375b358798c7a8f9b499c4881 (patch)
tree7942fd4a0b55795b7fb19c2e028ea54e637c7cf4 /modules
parent23f072887935a6aa81634ef487432ff2b5fa250a (diff)
downloadgitea-05e37264154bbcb375b358798c7a8f9b499c4881.tar.gz
gitea-05e37264154bbcb375b358798c7a8f9b499c4881.zip
Use default avatar on error
Diffstat (limited to 'modules')
-rw-r--r--modules/base/tool.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/base/tool.go b/modules/base/tool.go
index 0f730868eb..1bf1ce3951 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -192,6 +192,10 @@ func HashEmail(email string) string {
return EncodeMD5(strings.ToLower(strings.TrimSpace(email)))
}
+func DefaultAvatarLink() string {
+ return setting.AppSubURL + "/img/avatar_default.png"
+}
+
// AvatarLink returns relative avatar link to the site domain by given email,
// which includes app sub-url as prefix. However, it is possible
// to return full URL if user enables Gravatar-like service.
@@ -200,6 +204,7 @@ func AvatarLink(email string) string {
url, err := setting.LibravatarService.FromEmail(email)
if err != nil {
log.Error(4, "LibravatarService.FromEmail(email=%s): error %v", email, err)
+ return DefaultAvatarLink()
}
return url
}
@@ -208,7 +213,7 @@ func AvatarLink(email string) string {
return setting.GravatarSource + HashEmail(email)
}
- return setting.AppSubURL + "/img/avatar_default.png"
+ return DefaultAvatarLink()
}
// Seconds-based time units