diff --git a/server/static.ts b/server/static.ts index 0f02bbd..5adabda 100644 --- a/server/static.ts +++ b/server/static.ts @@ -10,6 +10,15 @@ function escapeHtml(str: string): string { function ogImageUrl(coverImage: string, baseUrl: string): string { if (!coverImage) return ""; let imgPath = coverImage; + // Cloudinary: vsili FB razmerje 1200x630 z g_faces (da FB ne reze glav) + if (imgPath.includes("res.cloudinary.com")) { + imgPath = imgPath.replace(/([,&/?])h_\d+/i, "$1h_630").replace(/([,&/?])w_\d+/i, "$1w_1200"); + // ce ni g_faces, ga dodaj + if (!/g_faces/.test(imgPath)) { + imgPath = imgPath.replace(/\/(image\/(upload|fetch))\//, "/$1/g_faces,"); + } + return imgPath; + } if (imgPath.endsWith(".webp")) { imgPath = imgPath.replace(/\.webp$/, ".jpg"); } @@ -102,8 +111,8 @@ export function serveStatic(app: Express) { ``, ``, ``, - ``, - ``, + ``, + ``, ``, ``, ``,