MCPcopy Create free account
hub / github.com/gogs/gogs / AvatarLink

Function AvatarLink

internal/tool/tool.go:130–146  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

128// which includes app sub-url as prefix. However, it is possible
129// to return full URL if user enables Gravatar-like service.
130func 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.
149func AppendAvatarSize(url string, size int) string {

Callers 2

AvatarURLPathMethod · 0.92
AvatarLinkMethod · 0.92

Calls 1

HashEmailFunction · 0.85

Tested by

no test coverage detected