Improve social media sharing by fixing image metadata for videos

Fix missing closing tags and incorrect image type for Open Graph and Twitter image meta tags in server-side rendering.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 401e2ec0-e00d-4f10-9d0e-60f3d479f9a5
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 3229ae0c-72b3-4c09-b860-17774f8ea99c
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/60d372ff-2c10-46c7-b01b-10c3435136b0/401e2ec0-e00d-4f10-9d0e-60f3d479f9a5/a97MHcj
This commit is contained in:
sebastjanartic 2026-01-24 13:13:04 +00:00
parent 1b1d3893a6
commit 5ef02b24ea
2 changed files with 8 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View File

@ -151,14 +151,19 @@ app.use((req, res, next) => {
// Replace og:image - handle both with and without id attribute
template = template.replace(
/<meta property="og:image"[^>]*>/,
`<meta property="og:image" id="og-image" content="${thumbnailUrl}"`
`<meta property="og:image" id="og-image" content="${thumbnailUrl}">`
);
// Replace og:image:type to match JPG format
template = template.replace(
/<meta property="og:image:type" content="[^"]*"/,
`<meta property="og:image:type" content="image/jpeg"`
);
// Zamenjamo tudi Twitter image
// Replace Twitter image - handle both with and without id attribute
template = template.replace(
/<meta name="twitter:image"[^>]*>/,
`<meta name="twitter:image" id="twitter-image" content="${thumbnailUrl}"`
`<meta name="twitter:image" id="twitter-image" content="${thumbnailUrl}">`
);
template = template.replace(