Improve social media sharing image generation for better platform visibility
Add an API endpoint to generate optimized social share images, resolving issues with image display on platforms like WhatsApp. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 2cd2c0bc-434c-4bc9-ad3f-b99d3897a0d1 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/2cd2c0bc-434c-4bc9-ad3f-b99d3897a0d1/OdlP8Wj
This commit is contained in:
parent
cde914729f
commit
1d1cbe4271
@ -11,8 +11,9 @@
|
||||
<meta property="og:description" content="Video-Welt von Folx TV – immer bei dir" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:site_name" content="go4.video" />
|
||||
<meta property="og:locale" content="en_US" />
|
||||
<meta property="og:image" content="/go4-video-social-share.png" />
|
||||
<meta property="og:locale" content="de_DE" />
|
||||
<meta property="og:url" content="https://go4video.replit.app/" />
|
||||
<meta property="og:image" content="https://go4video.replit.app/api/social-image" />
|
||||
<meta property="og:image:width" content="1200" />
|
||||
<meta property="og:image:height" content="630" />
|
||||
<meta property="og:image:type" content="image/png" />
|
||||
@ -22,7 +23,7 @@
|
||||
<meta name="twitter:site" content="@go4video" />
|
||||
<meta name="twitter:title" content="go4.video – Video-Welt von Folx TV" />
|
||||
<meta name="twitter:description" content="Video-Welt von Folx TV – immer bei dir" />
|
||||
<meta name="twitter:image" content="/go4-video-social-share.png" />
|
||||
<meta name="twitter:image" content="https://go4video.replit.app/api/social-image" />
|
||||
|
||||
<!-- Dodatni meta podatki za mobilne naprave -->
|
||||
<meta name="application-name" content="go4.video" />
|
||||
|
||||
@ -698,6 +698,42 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
}
|
||||
});
|
||||
|
||||
// Optimized social image endpoint
|
||||
app.get('/api/social-image', async (req, res) => {
|
||||
try {
|
||||
const fs = await import('fs');
|
||||
const path = await import('path');
|
||||
|
||||
// Read the original social share image
|
||||
const imagePath = path.join(process.cwd(), 'client/public/go4-video-social-share.png');
|
||||
|
||||
if (!fs.existsSync(imagePath)) {
|
||||
return res.status(404).send('Social image not found');
|
||||
}
|
||||
|
||||
const originalImage = fs.readFileSync(imagePath);
|
||||
|
||||
// Optimize with Sharp for WhatsApp/social media (under 300KB)
|
||||
const optimizedBuffer = await sharp(originalImage)
|
||||
.resize(1200, 630, { fit: 'cover' })
|
||||
.png({
|
||||
quality: 80,
|
||||
compressionLevel: 9,
|
||||
progressive: true
|
||||
})
|
||||
.toBuffer();
|
||||
|
||||
res.setHeader('Content-Type', 'image/png');
|
||||
res.setHeader('Cache-Control', 'public, max-age=86400'); // Cache for 24 hours
|
||||
res.setHeader('Content-Length', optimizedBuffer.length);
|
||||
res.send(optimizedBuffer);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error generating optimized social image:', error);
|
||||
res.status(500).send('Error generating social image');
|
||||
}
|
||||
});
|
||||
|
||||
// Favicon generation endpoint
|
||||
app.get('/api/favicon', async (req, res) => {
|
||||
try {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user