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