all repos — weimar @ fb3daf470ec0942e6de2372f28aeb79c53d22ed4

Unnamed repository; edit this file 'description' to name the repository.

feat: use full-resolution download URL for og:image previews

Images now point to the original file instead of the 300px thumbnail,
giving Discord/Telegram the highest quality preview frame. For videos,
the thumbnail is kept as a static poster since the download is a video
file. The body image in the OG page uses the same URL.

Assisted-by: Crush:deepseek-v4-flash
Maxwell Jensen maxwelljensen@posteo.net
Thu, 14 May 2026 11:34:32 +0200
commit

fb3daf470ec0942e6de2372f28aeb79c53d22ed4

parent

0ba068faac3861b09c7dc896d508fa45e594e23e

2 files changed, 18 insertions(+), 3 deletions(-)

jump to
M internal/server/server.gointernal/server/server.go

@@ -229,6 +229,14 @@ }

isVideo := strings.HasPrefix(img.MimeType, "video/") + // For images (including GIFs), use the full-resolution download URL as the + // og:image so platforms display a high-quality preview. For videos, use the + // thumbnail as a static poster frame since the download URL is a video file. + ogImageURL := thumbURL + if !isVideo { + ogImageURL = downloadURL + } + w.Header().Set("Content-Type", "text/html; charset=utf-8") fmt.Fprintf(w, `<!DOCTYPE html>

@@ -254,9 +262,9 @@ `,

htmlEsc(title), htmlEsc(description), htmlEsc(title), htmlEsc(description), htmlEsc(pageURL), - htmlEsc(thumbURL), htmlEsc(thumbURL), + htmlEsc(ogImageURL), htmlEsc(ogImageURL), img.Width, img.Height, - htmlEsc(title), htmlEsc(description), htmlEsc(thumbURL)) + htmlEsc(title), htmlEsc(description), htmlEsc(ogImageURL)) if isVideo { fmt.Fprintf(w, `<meta property="og:type" content="video">

@@ -292,7 +300,7 @@ </head>

<body> <img src="%s" alt="%s" style="max-width:100%%"> </body> -</html>`, idStr, htmlEsc(thumbURL), htmlEsc(title)) +</html>`, idStr, htmlEsc(ogImageURL), htmlEsc(title)) } func handleHealth(w http.ResponseWriter, r *http.Request) {
M internal/server/server_test.gointernal/server/server_test.go

@@ -94,6 +94,13 @@ }

if !strings.Contains(html, "1920") { t.Errorf("expected width in OG image:width, got:\n%s", html) } + // For images, og:image should point to the download URL (full-res), not thumbnail. + if !strings.Contains(html, "/download") { + t.Errorf("expected og:image to use download URL (full-res) for images, got:\n%s", html) + } + if strings.Contains(html, "/thumbnail") { + t.Errorf("og:image should use download URL for images, not thumbnail:\n%s", html) + } if strings.Contains(html, "&amp;") || strings.Contains(html, "&lt;") { t.Errorf("HTML appears double-escaped:\n%s", html) }