Download the PHP package hosmelq/laravel-open-graph-image without Composer
On this page you can find all versions of the php package hosmelq/laravel-open-graph-image. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hosmelq/laravel-open-graph-image
More information about hosmelq/laravel-open-graph-image
Files in hosmelq/laravel-open-graph-image
Package laravel-open-graph-image
Short Description Generate Open Graph images for your Laravel application.
License MIT
Informations about the package laravel-open-graph-image
Laravel Open Graph Image
Generate dynamic Open Graph images for Laravel applications using Blade templates and Tailwind CSS.
See it in action: a real Open Graph image generated from a Blade + Tailwind template.
Source: https://laravel-open-graph-image.hosmelq.com/open-graph-image?template=demo
Introduction
Using this package, you can generate Open Graph images from Blade templates styled with Tailwind CSS. Whether you want to create preview images for blog posts, product cards, or event announcements, this package handles it all.
The image is generated when accessed and cached for subsequent requests.
Requirements
- PHP 8.2+
- Laravel 12+
- Node.js and npm
- PHP extension ext-fileinfo (required for @embedImage)
Installation & setup
You can install the package via composer:
Publishing the config file
Optionally, you can publish the config file with this command:
View the published config file.
Configuring Browsershot
This package uses Browsershot for screenshot generation. For detailed requirements and installation instructions, see the Browsershot requirements.
To get started, you'll need to install Puppeteer:
Downloading Tailwind CLI
Download the Tailwind CSS v4 binary:
Basic usage
Getting started
Let's generate an Open Graph image for a blog post. We'll create a Blade template and add the meta component to your page.
First, create a template in resources/views/open-graph-image/templates/post.blade.php
:
Now, add the meta component to your page:
The meta component outputs og:image
, og:image:width
, og:image:height
, og:image:type
, twitter:card
, and twitter:image
meta tags. The image is generated when accessed and cached for subsequent requests.
Programmatically generating images
Generate images directly in your code:
Using the preview mode
During development, preview your templates as HTML without generating images:
The preview route is only available in the local environment by default.
[!TIP] Use your browser's Responsive Mode with a 1200×630 viewport to preview templates at the exact Open Graph image dimensions. This speeds up design iteration without regenerating PNGs.
Creating templates
Templates are Blade views stored in resources/views/open-graph-image/templates/
.
Simple template
Demo template
Using the image embedding directive
The @embedImage
directive converts local images to data URIs. Use paths like public_path('images/logo.png')
:
Customizing CSS
The package processes your templates with Tailwind CSS v4. To use custom CSS, publish the default file:
This creates resources/vendor/open-graph-image/css/open-graph-image.css
that you can modify:
Alternatively, use your own CSS file from any location:
Testing
Changelog
Please see CHANGELOG.md for more information on what has changed recently.
Credits
- Hosmel Quintana
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-open-graph-image with dependencies
laravel/framework Version ^12.0
spatie/browsershot Version ^5.0
spatie/laravel-package-tools Version ^1.92
spatie/temporary-directory Version ^2.3
symfony/process Version ^7.3
thecodingmachine/safe Version ^3.3