shorten URLs when rendering text image so they don't use all the space.

This commit is contained in:
fiatjaf
2023-12-25 23:18:23 -03:00
parent 3d20906bab
commit 28d7a73adf
2 changed files with 38 additions and 1 deletions

View File

@@ -52,6 +52,7 @@ func renderImage(w http.ResponseWriter, r *http.Request) {
content := strings.Replace(data.event.Content, "\n\n\n\n", "\n\n", -1)
content = strings.Replace(data.event.Content, "\n\n\n", "\n\n", -1)
content = shortenURLs(content)
// this turns the raw event.Content into a series of lines ready to drawn
paragraphs := replaceUserReferencesWithNames(r.Context(),
@@ -72,7 +73,6 @@ func renderImage(w http.ResponseWriter, r *http.Request) {
if err := png.Encode(w, img); err != nil {
log.Printf("error encoding image: %s", err)
http.Error(w, "error encoding image!", 500)
return
}
}