og:image: Cloudinary g_faces 1200x630 (FB ne reze glav)
This commit is contained in:
parent
0e5ab138cb
commit
f51c21c716
@ -10,6 +10,15 @@ function escapeHtml(str: string): string {
|
|||||||
function ogImageUrl(coverImage: string, baseUrl: string): string {
|
function ogImageUrl(coverImage: string, baseUrl: string): string {
|
||||||
if (!coverImage) return "";
|
if (!coverImage) return "";
|
||||||
let imgPath = coverImage;
|
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")) {
|
if (imgPath.endsWith(".webp")) {
|
||||||
imgPath = imgPath.replace(/\.webp$/, ".jpg");
|
imgPath = imgPath.replace(/\.webp$/, ".jpg");
|
||||||
}
|
}
|
||||||
@ -102,8 +111,8 @@ export function serveStatic(app: Express) {
|
|||||||
`<meta property="og:url" content="${escapeHtml(articleUrl)}" />`,
|
`<meta property="og:url" content="${escapeHtml(articleUrl)}" />`,
|
||||||
`<meta property="og:image" content="${escapeHtml(finalImage)}" />`,
|
`<meta property="og:image" content="${escapeHtml(finalImage)}" />`,
|
||||||
`<meta property="og:image:secure_url" content="${escapeHtml(finalImage)}" />`,
|
`<meta property="og:image:secure_url" content="${escapeHtml(finalImage)}" />`,
|
||||||
`<meta property="og:image:width" content="800" />`,
|
`<meta property="og:image:width" content="1200" />`,
|
||||||
`<meta property="og:image:height" content="450" />`,
|
`<meta property="og:image:height" content="630" />`,
|
||||||
`<meta property="og:image:type" content="image/jpeg" />`,
|
`<meta property="og:image:type" content="image/jpeg" />`,
|
||||||
`<meta property="og:site_name" content="Folx Music Television" />`,
|
`<meta property="og:site_name" content="Folx Music Television" />`,
|
||||||
`<meta property="og:locale" content="de_DE" />`,
|
`<meta property="og:locale" content="de_DE" />`,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user