support multiple og:image tags (#2305)
parent
b5d53ef0b9
commit
929987f806
|
@ -336,7 +336,11 @@ func (srv *Server) WebPost(c echo.Context) error {
|
||||||
data["postView"] = postView
|
data["postView"] = postView
|
||||||
data["requestURI"] = fmt.Sprintf("https://%s%s", req.Host, req.URL.Path)
|
data["requestURI"] = fmt.Sprintf("https://%s%s", req.Host, req.URL.Path)
|
||||||
if postView.Embed != nil && postView.Embed.EmbedImages_View != nil {
|
if postView.Embed != nil && postView.Embed.EmbedImages_View != nil {
|
||||||
data["imgThumbUrl"] = postView.Embed.EmbedImages_View.Images[0].Thumb
|
var thumbUrls []string
|
||||||
|
for i := range postView.Embed.EmbedImages_View.Images {
|
||||||
|
thumbUrls = append(thumbUrls, postView.Embed.EmbedImages_View.Images[i].Thumb)
|
||||||
|
}
|
||||||
|
data["imgThumbUrls"] = thumbUrls
|
||||||
}
|
}
|
||||||
return c.Render(http.StatusOK, "post.html", data)
|
return c.Render(http.StatusOK, "post.html", data)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,10 @@
|
||||||
<meta name="description" content="{{ postView.Record.Val.Text }}">
|
<meta name="description" content="{{ postView.Record.Val.Text }}">
|
||||||
<meta property="og:description" content="{{ postView.Record.Val.Text }}">
|
<meta property="og:description" content="{{ postView.Record.Val.Text }}">
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
{%- if imgThumbUrl %}
|
{%- if imgThumbUrls %}
|
||||||
|
{% for imgThumbUrl in imgThumbUrls %}
|
||||||
<meta property="og:image" content="{{ imgThumbUrl }}">
|
<meta property="og:image" content="{{ imgThumbUrl }}">
|
||||||
|
{% endfor %}
|
||||||
<meta name="twitter:card" content="summary_large_image">
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
{%- elif postView.Author.Avatar %}
|
{%- elif postView.Author.Avatar %}
|
||||||
{# Don't use avatar image in cards; usually looks bad #}
|
{# Don't use avatar image in cards; usually looks bad #}
|
||||||
|
|
Loading…
Reference in New Issue