Dev Team Builds PHP-Based Dynamic OGP Image Generator After Blog Posts Showed Sales Banner
A development team discovered that all 42 blog posts across their English and Japanese blog were displaying a sales banner instead of relevant preview images when shared on social platforms like X and LinkedIn. The root cause was the WordPress theme's fallback OGP logic, which defaulted to the site's LP sales banner whenever no featured image was assigned — and none of the 42 posts had one. Rather than manually creating individual images for each post, the team built a dynamic OGP image generator using PHP's GD library, following a pattern used by platforms like Vercel and dev.to. The solution, contained in a single ~375-line PHP file, renders a 1200×630 PNG card on demand using each post's title, then caches it to disk for subsequent requests. The approach eliminates ongoing artwork overhead and ensures every future post automatically receives a correctly composed, per-article preview image.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in