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.
(email string)
| 128 | // which includes app sub-url as prefix. However, it is possible |
| 129 | // to return full URL if user enables Gravatar-like service. |
| 130 | func AvatarLink(email string) (url string) { |
| 131 | if conf.Picture.EnableFederatedAvatar && conf.Picture.LibravatarService != nil && |
| 132 | strings.Contains(email, "@") { |
| 133 | var err error |
| 134 | url, err = conf.Picture.LibravatarService.FromEmail(email) |
| 135 | if err != nil { |
| 136 | log.Warn("AvatarLink.LibravatarService.FromEmail [%s]: %v", email, err) |
| 137 | } |
| 138 | } |
| 139 | if url == "" && !conf.Picture.DisableGravatar { |
| 140 | url = conf.Picture.GravatarSource + HashEmail(email) + "?d=identicon" |
| 141 | } |
| 142 | if url == "" { |
| 143 | url = conf.Server.Subpath + "/img/avatar_default.png" |
| 144 | } |
| 145 | return url |
| 146 | } |
| 147 | |
| 148 | // AppendAvatarSize appends avatar size query parameter to the URL in the correct format. |
| 149 | func AppendAvatarSize(url string, size int) string { |
no test coverage detected