mirror of
https://github.com/go-gitea/gitea
synced 2025-07-13 14:07:20 +00:00
Alwaywas return local url for users avatar (#8245)
* Always return local url for users avatar Avoids having to wait for DNS lookups when libravatar is activated fixing #6046 * Avoid double slash in avatar link * Move avatar route to the correct place
This commit is contained in:
committed by
techknowlogick
parent
b2b927808b
commit
d958b9db4f
@ -17,6 +17,7 @@ import (
|
||||
"image/png"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
@ -374,9 +375,20 @@ func (u *User) generateRandomAvatar(e Engine) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SizedRelAvatarLink returns a relative link to the user's avatar. When
|
||||
// applicable, the link is for an avatar of the indicated size (in pixels).
|
||||
// SizedRelAvatarLink returns a link to the user's avatar via
|
||||
// the local explore page. Function returns immediately.
|
||||
// When applicable, the link is for an avatar of the indicated size (in pixels).
|
||||
func (u *User) SizedRelAvatarLink(size int) string {
|
||||
return strings.TrimRight(setting.AppSubURL, "/") + "/user/avatar/" + u.Name + "/" + strconv.Itoa(size)
|
||||
}
|
||||
|
||||
// RealSizedAvatarLink returns a link to the user's avatar. When
|
||||
// applicable, the link is for an avatar of the indicated size (in pixels).
|
||||
//
|
||||
// This function make take time to return when federated avatars
|
||||
// are in use, due to a DNS lookup need
|
||||
//
|
||||
func (u *User) RealSizedAvatarLink(size int) string {
|
||||
if u.ID == -1 {
|
||||
return base.DefaultAvatarLink()
|
||||
}
|
||||
|
Reference in New Issue
Block a user