New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

spatie/laravel-og-image

Generate OG images for your Laravel app
138,371 38

Larablocks Analysis

Compatibility

Trusted maintainer

spatie/laravel-og-image works with Laravel 12 and 13 (latest release 1.3.2, Oct 2, 2026).

  • Trusted maintainer: spatie publishes 287 packages on Larablocks, with 204,136,623 downloads a month between them.

Recommendation checks

Solid choice

Solid choice: maintained and up to date, meets 3 of 4 checks; below the bar for Recommended on use.

  • Works with Laravel 13, the current version
  • Released in the last 12 months (Oct 2, 2026)
  • 14,697 downloads a month (at least 10,000)
  • 38 GitHub stars (needs 100)

State

Actively maintained
  • Last stable release: Oct 2, 2026.
  • 13 releases in the last 12 months.
  • First released: Feb 19, 2026.
  • Monthly downloads: 14,697, down 16% from six months ago.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Dec 1, 2026.

Install
composer require spatie/laravel-og-image
Latest Version:1.3.2
PHP:^8.3
Laravel:12 · 13
License:MIT
Last Updated:Nov 6, 2026
Links: GitHub  ·  Packagist
Maintainer: spatie
Logo for Laravel Open Graph Image

Generate OG images for your Laravel app

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package makes it easy to generate Open Graph images for your Laravel application. Define your OG image HTML inline in your Blade views, and the package automatically generates screenshot images using spatie/laravel-screenshot, serves them via a dedicated route, and caches them on disk.

Your OG image templates inherit your page's existing CSS, fonts, and Vite assets. No separate CSS configuration needed.

No external API needed. Everything runs on your own server.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Documentation

You'll find full documentation on our documentation site.

Basic usage

Use the Blade component to define your OG image inline:

<x-og-image>
    <div class="w-full h-full bg-blue-900 text-white flex items-center justify-center">
        <h1 class="text-6xl font-bold">{{ $post->title }}</h1>
    </div>
</x-og-image>

This outputs a hidden <template> tag and <meta> tags pointing to a generated screenshot of your HTML at 1200×630 pixels.

How it works

  1. Your HTML is rendered inside a <template data-og-image> tag on the page
  2. The page URL is cached, keyed by the md5 hash of the HTML content
  3. Meta tags point to /og-image/{hash}.jpeg
  4. When that URL is first requested, the page is visited with ?ogimage appended, rendering just the template content with the page's full CSS at 1200×630
  5. The generated image is saved to your public disk and served directly with cache headers
  6. Subsequent requests serve the image from disk (or CDN cache)

Preview any OG image by appending ?ogimage to the page URL.

Installation

You can install the package via composer:

composer require spatie/laravel-og-image

This package requires spatie/laravel-screenshot, which uses Browsershot under the hood. Make sure you have Node.js and a Chrome/Chromium binary installed.

You can optionally publish the config file:

php artisan vendor:publish --tag="og-image-config"

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

vormkracht10/laravel-open-graph-image

Laravel package to generate dynamic Open Graph images

18,939 69
mischasigtermans/laravel-ogkit

Dynamic OG images for Laravel. Design social previews with your own HTML and CSS...

1,196 1
spatie/elasticsearch-search-string-parser

Build Elasticsearch queries based of a query string

24,619 51
spatie/backtrace

A better backtrace

220,267,784 438
spatie/laravel-package-tools

Tools for creating Laravel packages

208,094,001 952

Version History

Version Released PHP Laravel License
1.3.2 ^8.3 ^12.0|^13.0 MIT
1.3.1 ^8.3 ^12.0|^13.0 MIT
1.3.0 ^8.3 ^12.0|^13.0 MIT
1.2.0 ^8.3 ^12.0 MIT
1.1.4 ^8.3 ^12.0|^13.0 MIT