Bluesky app fork with some witchin' additions 💫 witchsky.app
bluesky fork client

bskyweb: use avatar thumbnail for post og:image fallback (#9923)

authored by samuel.fm and committed by

GitHub 8b1c47a4 c2fd87bd

+9 -2
+7
bskyweb/cmd/bskyweb/filters.go
··· 2 2 3 3 import ( 4 4 "net/url" 5 + "strings" 5 6 6 7 "github.com/flosch/pongo2/v6" 7 8 ) 8 9 9 10 func init() { 10 11 pongo2.RegisterFilter("canonicalize_url", filterCanonicalizeURL) 12 + pongo2.RegisterFilter("avatar_thumbnail", filterAvatarThumbnail) 11 13 } 12 14 13 15 func filterCanonicalizeURL(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) { ··· 26 28 // Return the cleaned URL 27 29 return pongo2.AsValue(parsedURL.String()), nil 28 30 } 31 + 32 + func filterAvatarThumbnail(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) { 33 + urlStr := in.String() 34 + return pongo2.AsValue(strings.Replace(urlStr, "/img/avatar/plain/", "/img/avatar_thumbnail/plain/", 1)), nil 35 + }
+2 -2
bskyweb/templates/post.html
··· 35 35 {% endfor %} 36 36 <meta name="twitter:card" content="summary_large_image"> 37 37 {% else %} 38 - <meta property="og:image" content="{{ postView.Author.Avatar }}"> 39 - <meta property="twitter:image" content="{{ postView.Author.Avatar }}"> 38 + <meta property="og:image" content="{{ postView.Author.Avatar|avatar_thumbnail }}"> 39 + <meta property="twitter:image" content="{{ postView.Author.Avatar|avatar_thumbnail }}"> 40 40 <meta name="twitter:card" content="summary"> 41 41 {% endif %} 42 42 <meta name="twitter:label1" content="Posted At">