Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenGraph: use repo avatar if exist #12586

Merged
merged 2 commits into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2254,6 +2254,11 @@ func (repo *Repository) relAvatarLink(e Engine) string {
return setting.AppSubURL + "/repo-avatars/" + repo.Avatar
}

// AvatarLink returns a link to the repository's avatar.
func (repo *Repository) AvatarLink() string {
return repo.avatarLink(x)
}

// avatarLink returns user avatar absolute link.
func (repo *Repository) avatarLink(e Engine) string {
link := repo.relAvatarLink(e)
Expand Down
6 changes: 5 additions & 1 deletion templates/base/head.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@
{{end}}
{{end}}
<meta property="og:type" content="object" />
<meta property="og:image" content="{{.Repository.Owner.AvatarLink}}" />
{{if .Repository.AvatarLink}}
<meta property="og:image" content="{{.Repository.AvatarLink}}" />
{{else}}
<meta property="og:image" content="{{.Repository.Owner.AvatarLink}}" />
{{end}}
{{else}}
<meta property="og:title" content="{{AppName}}">
<meta property="og:type" content="website" />
Expand Down