about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsnek <me@gus.host>2023-12-27 09:13:53 -0800
committerGitHub <noreply@github.com>2023-12-27 18:13:53 +0100
commit929987f8061ba55de84b65e40d4e1df747fe7028 (patch)
tree731c0e46e1a1485555746da705735128de5049f7
parentb5d53ef0b9ec5e109710b6b21419913a3683b743 (diff)
downloadvoidsky-929987f8061ba55de84b65e40d4e1df747fe7028.tar.zst
support multiple og:image tags (#2305)
-rw-r--r--bskyweb/cmd/bskyweb/server.go6
-rw-r--r--bskyweb/templates/post.html4
2 files changed, 8 insertions, 2 deletions
diff --git a/bskyweb/cmd/bskyweb/server.go b/bskyweb/cmd/bskyweb/server.go
index b0fde2557..7a3b8bf16 100644
--- a/bskyweb/cmd/bskyweb/server.go
+++ b/bskyweb/cmd/bskyweb/server.go
@@ -336,7 +336,11 @@ func (srv *Server) WebPost(c echo.Context) error {
 	data["postView"] = postView
 	data["requestURI"] = fmt.Sprintf("https://%s%s", req.Host, req.URL.Path)
 	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)
 }
diff --git a/bskyweb/templates/post.html b/bskyweb/templates/post.html
index 55a0679fb..307f80bbb 100644
--- a/bskyweb/templates/post.html
+++ b/bskyweb/templates/post.html
@@ -25,8 +25,10 @@
   <meta name="description" content="{{ postView.Record.Val.Text }}">
   <meta property="og:description" content="{{ postView.Record.Val.Text }}">
   {% endif -%}
-  {%- if imgThumbUrl %}
+  {%- if imgThumbUrls %}
+  {% for imgThumbUrl in imgThumbUrls %}
   <meta property="og:image" content="{{ imgThumbUrl }}">
+  {% endfor %}
   <meta name="twitter:card" content="summary_large_image">
   {%- elif postView.Author.Avatar %}
   {# Don't use avatar image in cards; usually looks bad #}