SShortSingh.
Back to feed

Dev Team Builds PHP-Based Dynamic OGP Image Generator After Blog Posts Showed Sales Banner

0
·1 views

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.

Read the full story at DEV Community

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

Related stories

0
ProgrammingDEV Community ·

Free Batch Image Converter Uses Photopea to Handle HEIC, WebP, JPG at Scale

Full-stack developer Mohamed ben mallessa has published a technical guide detailing how to batch-convert large volumes of images — including HEIC, WebP, and JPG formats — without paid tools or manual effort. The solution leverages Photopea, a free browser-based image editor, as a conversion engine driven by a custom script. Unlike ImageMagick, which requires specific codecs, or online converters with file-size limits, this approach handles hundreds of files locally without uploading them to any server. The script supports configurable output format, quality, and resizing, while preserving the original folder structure. Originally published as a GitHub Gist, the guide targets developers who regularly deal with bulk image processing workflows.

0
ProgrammingDEV Community ·

How the Linux Kernel Uses CPU Rings and Syscalls to Isolate Processes

Modern operating systems prevent processes from accessing arbitrary hardware or other processes' memory using built-in CPU architecture features, not software checks on every instruction. On x86, processors operate in privilege levels called rings: the kernel runs in Ring 0 with full hardware access, while user programs run in Ring 3 with restricted permissions. Whenever an interrupt or a system call occurs, the CPU automatically switches to Ring 0, returning control to the kernel's pre-configured handlers. When a user-space program needs hardware access — such as reading a file — it issues a syscall instruction, prompting the kernel to verify permissions and perform the operation on the process's behalf. Memory isolation between processes is enforced through virtual memory, another hardware-level feature that maps each process to its own address space without exposing others.

0
ProgrammingDEV Community ·

Pakistani CS Student Builds RAG-Powered AI Tool to Make Law Accessible to All

A computer science student at Sukkur IBA University in interior Sindh has developed HAQ, an AI-powered legal assistant aimed at making Pakistani law accessible to citizens who cannot afford lawyers. The tool uses Retrieval-Augmented Generation (RAG), meaning it only provides legal information backed by retrieved passages from actual Pakistani legislation, with direct source links, to avoid the hallucination problem common in standard AI models. Pakistan's 220 million citizens are technically protected by hundreds of laws, but high lawyer fees, understaffed legal aid, and legislation written in English create a steep access barrier for most people. Building the system required collecting and processing over 100 Acts from scattered, inconsistently digitized government portals across federal and provincial sources. The project's name, HAQ, is an Arabic and Urdu word meaning 'right' — reflecting the developer's goal of helping citizens understand what is legally theirs.

0
ProgrammingDEV Community ·

Beginner Developer Builds Open Source Ethical Hacking Tool Entirely on a Smartphone

A self-described beginner developer has created an open source ethical hacking and security audit tool called ImCurvin, built entirely using a smartphone touchscreen. The project comprises approximately 1,155 lines of code, split between Bash and Python, and is designed with a minimalist approach. The tool features a modular structure with separate payload directories, though the developer acknowledges the formatting may appear inconsistent due to the constraints of mobile typing. Published on GitHub, the project is open to community contributions via pull requests and issue submissions. The developer, who does not yet own a PC, is actively seeking help from the community to clean up and optimize the codebase.

Dev Team Builds PHP-Based Dynamic OGP Image Generator After Blog Posts Showed Sales Banner · ShortSingh