summaryrefslogtreecommitdiffstats
path: root/models/user.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-08-07 10:13:05 -0700
committerUnknwon <u@gogs.io>2016-08-07 10:13:05 -0700
commitec92565f234deb75ea8df0c30a8772c4cd72bc2d (patch)
tree3b0f4885e1d9ab1afa1352a98f36f1ae702166c7 /models/user.go
parent2772791fdad8f0ec4ae49aad020f8afdff2f9c46 (diff)
downloadgitea-ec92565f234deb75ea8df0c30a8772c4cd72bc2d.tar.gz
gitea-ec92565f234deb75ea8df0c30a8772c4cd72bc2d.zip
#3393 fix missing sub-url prefix in relative avatar link
Diffstat (limited to 'models/user.go')
-rw-r--r--models/user.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/models/user.go b/models/user.go
index ac3d2e819b..941dc054aa 100644
--- a/models/user.go
+++ b/models/user.go
@@ -230,8 +230,11 @@ func (u *User) GenerateRandomAvatar() error {
return nil
}
+// RelAvatarLink returns relative avatar link to the site domain,
+// which includes app sub-url as prefix. However, it is possible
+// to return full URL if user enables Gravatar-like service.
func (u *User) RelAvatarLink() string {
- defaultImgUrl := "/img/avatar_default.png"
+ defaultImgUrl := setting.AppSubUrl + "/img/avatar_default.png"
if u.ID == -1 {
return defaultImgUrl
}
@@ -241,7 +244,7 @@ func (u *User) RelAvatarLink() string {
if !com.IsExist(u.CustomAvatarPath()) {
return defaultImgUrl
}
- return "/avatars/" + com.ToStr(u.ID)
+ return setting.AppSubUrl + "/avatars/" + com.ToStr(u.ID)
case setting.DisableGravatar, setting.OfflineMode:
if !com.IsExist(u.CustomAvatarPath()) {
if err := u.GenerateRandomAvatar(); err != nil {
@@ -249,7 +252,7 @@ func (u *User) RelAvatarLink() string {
}
}
- return "/avatars/" + com.ToStr(u.ID)
+ return setting.AppSubUrl + "/avatars/" + com.ToStr(u.ID)
}
return setting.GravatarSource + u.Avatar
}