Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Og Image Laravel Package

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.

View on GitHub
Deep Wiki
Context7

title: Pre-generating images weight: 6

By default, OG images are generated lazily, on the first request from a crawler. This means the first crawler to request the image triggers a Chrome screenshot, which takes a few seconds. If many new pages go live at the same time, this can lead to multiple concurrent screenshot processes and put load on your server.

To avoid this, you can pre-generate images ahead of time.

Using the artisan command

php artisan og-image:generate https://yourapp.com/page1 https://yourapp.com/page2

Using generateForUrl()

You can generate an OG image programmatically by passing a page URL:

use Spatie\OgImage\Facades\OgImage;

$imageUrl = OgImage::generateForUrl('https://yourapp.com/blog/my-post');

This fetches the page, extracts the <x-og-image> template, takes a screenshot, and saves it to disk.

Generating after publishing content

A common pattern is to dispatch a queued job after saving content, so the OG image is ready before any crawler requests it:

use Spatie\OgImage\Facades\OgImage;

class PublishPostAction
{
    public function execute(Post $post): void
    {
        // ... publish logic ...

        dispatch(function () use ($post) {
            OgImage::generateForUrl($post->url);
        });
    }
}
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai