aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorEthan Koenig <ethantkoenig@gmail.com>2017-12-03 03:55:13 -0800
committerLunny Xiao <xiaolunwen@gmail.com>2017-12-03 19:55:13 +0800
commitab62da283aa20475109eba907324f55123d7e3c6 (patch)
treea08bb1753ff39d9ecc74afc42374ba614c67d8bb /models
parent7bab3d2fb1d75ac29ad6a9b11203ea358b1979d3 (diff)
downloadgitea-ab62da283aa20475109eba907324f55123d7e3c6.tar.gz
gitea-ab62da283aa20475109eba907324f55123d7e3c6.zip
Fix avatar URLs (#3069)
* Fix avatar URLs * import order
Diffstat (limited to 'models')
-rw-r--r--models/user.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/models/user.go b/models/user.go
index f3a74f5e08..31af3747c0 100644
--- a/models/user.go
+++ b/models/user.go
@@ -315,10 +315,9 @@ func (u *User) generateRandomAvatar(e Engine) 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 {
+// SizedRelAvatarLink returns a relative link to the user's avatar. When
+// applicable, the link is for an avatar of the indicated size (in pixels).
+func (u *User) SizedRelAvatarLink(size int) string {
if u.ID == -1 {
return base.DefaultAvatarLink()
}
@@ -338,7 +337,14 @@ func (u *User) RelAvatarLink() string {
return setting.AppSubURL + "/avatars/" + u.Avatar
}
- return base.AvatarLink(u.AvatarEmail)
+ return base.SizedAvatarLink(u.AvatarEmail, size)
+}
+
+// RelAvatarLink returns a relative link to the user's avatar. The link
+// may either be a sub-URL to this site, or a full URL to an external avatar
+// service.
+func (u *User) RelAvatarLink() string {
+ return u.SizedRelAvatarLink(base.DefaultAvatarSize)
}
// AvatarLink returns user avatar absolute link.