spatie/laravel-og-image
Generate Open Graph images in Laravel from Blade-defined HTML. Automatically renders screenshots, serves them from a route, and caches files. Templates reuse your app’s CSS, fonts, and Vite assets—no external API required.
When you visit a page with ?ogimage, the package renders a minimal HTML document that wraps your template content. This document includes the page's <head> (so CSS and fonts work) and a reset style that sets the viewport to the configured dimensions.
If you need to customize this layout (for example, to add extra styles, scripts, or change the document structure), you can publish the view:
php artisan vendor:publish --tag=og-image-views
This publishes screenshot.blade.php to resources/views/vendor/og-image/. The view receives these variables:
The contents of the original page's <head> tag, including all CSS, fonts, and Vite assets.
The HTML from your <x-og-image> component.
The configured width in pixels (default: 1200).
The configured height in pixels (default: 630).
For even deeper control over how the screenshot page is rendered, you can override the RenderOgImageScreenshotAction. See customizing actions for details.
How can I help you explore Laravel packages today?