diff options
author | silverwind <me@silverwind.io> | 2020-12-09 06:11:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-09 07:11:15 +0200 |
commit | 97ab820accba40de66d7df7cdc5e396277483710 (patch) | |
tree | 33fac74e7e37d055e066590532e915572f6d7948 /modules/templates | |
parent | 10b9a6df0d09b9865f7bd705b70b414d07d3f320 (diff) | |
download | gitea-97ab820accba40de66d7df7cdc5e396277483710.tar.gz gitea-97ab820accba40de66d7df7cdc5e396277483710.zip |
Fix action avatar loading (#13909)
Fixes #13883
Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'modules/templates')
-rw-r--r-- | modules/templates/helper.go | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go index f7c10c3698..a7063d7b8d 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -338,11 +338,12 @@ func NewFuncMap() []template.FuncMap { } return false }, - "svg": SVG, - "avatar": Avatar, - "avatarHTML": AvatarHTML, - "avatarByEmail": AvatarByEmail, - "repoAvatar": RepoAvatar, + "svg": SVG, + "avatar": Avatar, + "avatarHTML": AvatarHTML, + "avatarByAction": AvatarByAction, + "avatarByEmail": AvatarByEmail, + "repoAvatar": RepoAvatar, "SortArrow": func(normSort, revSort, urlSort string, isDefault bool) template.HTML { // if needed if len(normSort) == 0 || len(urlSort) == 0 { @@ -559,6 +560,12 @@ func Avatar(user *models.User, others ...interface{}) template.HTML { return template.HTML("") } +// AvatarByAction renders user avatars from action. args: action, size (int), class (string) +func AvatarByAction(action *models.Action, others ...interface{}) template.HTML { + action.LoadActUser() + return Avatar(action.ActUser, others...) +} + // RepoAvatar renders repo avatars. args: repo, size(int), class (string) func RepoAvatar(repo *models.Repository, others ...interface{}) template.HTML { size, class := parseOthers(models.DefaultAvatarPixelSize, "ui avatar image", others...) |