Browse Source

OpenGraph: use repo avatar if exist (#12586)

mj-v1.14.3
6543 2 years ago
committed by GitHub
parent
commit
4b97f9018b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      models/repo.go
  2. 6
      templates/base/head.tmpl

5
models/repo.go

@ -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)

6
templates/base/head.tmpl

@ -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" />

Loading…
Cancel
Save