PHPackages                             vormkracht10/laravel-open-graph-image - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. vormkracht10/laravel-open-graph-image

ActiveLibrary[Image &amp; Media](/categories/media)

vormkracht10/laravel-open-graph-image
=====================================

Laravel package to generate dynamic Open Graph images

v1.1.0(10mo ago)7217.7k↓40.9%4[2 PRs](https://github.com/backstagephp/laravel-og-image/pulls)MITPHPPHP ^8.2CI passing

Since Sep 9Pushed 4mo ago3 watchersCompare

[ Source](https://github.com/backstagephp/laravel-og-image)[ Packagist](https://packagist.org/packages/vormkracht10/laravel-open-graph-image)[ Docs](https://github.com/backstagephp/laravel-og-image)[ GitHub Sponsors](https://github.com/backstagephp)[ RSS](/packages/vormkracht10-laravel-open-graph-image/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (15)Versions (46)Used By (0)

Generate Dynamic Open Graph Images in Laravel using Blade Views
===============================================================

[](#generate-dynamic-open-graph-images-in-laravel-using-blade-views)

[![GitHub release (latest by date)](https://camo.githubusercontent.com/60c027f4caad1b20ff877517a74cea471a53d62b103b1bea7e412a78acab175e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6261636b73746167657068702f6c61726176656c2d6f672d696d616765)](https://camo.githubusercontent.com/60c027f4caad1b20ff877517a74cea471a53d62b103b1bea7e412a78acab175e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6261636b73746167657068702f6c61726176656c2d6f672d696d616765)[![Tests](https://github.com/backstagephp/laravel-og-image/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/vormkracht10/laravel-og-image/actions/workflows/run-tests.yml)[![Packagist PHP Version Support](https://camo.githubusercontent.com/e27e95ef63440bda16c92f2f8e4758a8ac972f3c435be21b15b6e07a22d39246/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6261636b73746167652f6c61726176656c2d6f672d696d616765)](https://camo.githubusercontent.com/e27e95ef63440bda16c92f2f8e4758a8ac972f3c435be21b15b6e07a22d39246/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6261636b73746167652f6c61726176656c2d6f672d696d616765)[![Latest Version on Packagist](https://camo.githubusercontent.com/71ac305afb3039366fa4c0f867dff477b46c2eb35b16cf4b855b14cc4dbb7cd4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6261636b73746167652f6c61726176656c2d6f672d696d6167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vormkracht10/laravel-og-image)[![Total Downloads](https://camo.githubusercontent.com/bdad0c8dca661b1f5d97dce1b188b2c942c131c18534d60e5d618e0ba8d57093/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6261636b73746167652f6c61726176656c2d6f672d696d6167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vormkracht10/laravel-og-image)

This Laravel package enables you to dynamically create Open Graph images for your website based on a single Blade template with HTML and CSS. In our example we use the Tailwind CDN. So designing a dynamic Open Graph Image as a developer just got very easy using this package!

Just add the meta tag with our url to the head of your page. The package will then generate the image and add it to the page. You can edit the view template which you can find in the resources folder.

- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
    - [Passing extra attributes](#passing-extra-attributes)
    - [Clearing cached images](#clearing-cached-images)
- [Changelog](#changelog)
- [Contributing](#contributing)
- [Security Vulnerabilities](#security-vulnerabilities)
- [Credits](#credits)
- [License](#license)

Requirements
------------

[](#requirements)

- PHP 8.2+

Installation
------------

[](#installation)

First install Google Chrome or Chromium, as you need the binary to use it as a headless browser.

### On macOS

[](#on-macos)

```
# Google Chrome
brew install --cask google-chrome
sudo xattr -rd com.apple.quarantine /Applications/Chrome.app # Remove quarantine macOS protection mechanism

# Chromium
brew install chromium
sudo xattr -rd com.apple.quarantine /Applications/Chromium.app # Remove quarantine macOS protection mechanism
```

### On Debian/Ubuntu

[](#on-debianubuntu)

For Ubuntu 22.04+ (Note: you'll need to update the environment variable of `CHROME_PATH` to `chomium-browser`)

```
sudo add-apt-repository ppa:savoury1/ffmpeg4
sudo add-apt-repository ppa:savoury1/chromium
sudo apt-get update
sudo apt-get install chromium-browser
```

For Ubuntu everything below 22.04

```
# Install chromium from PPA instead of snap, because of permission issues with snapd version
sudo add-apt-repository ppa:saiarcot895/chromium-dev -y
sudo apt update
sudo apt install chromium-browser -y
```

### On Windows

[](#on-windows)

Download and install [Google Chrome](https://google.com/chrome) or [Chromium](https://chromium.woolyss.com/download/) using on of these links.

### Note: configure path to Chrome/Chromium

[](#note-configure-path-to-chromechromium)

Sometimes it's necessary to point the package to a custom path where the binary is located, this can be set in the config `og-image.chrome.path`. The path can be retrieved using:

```
# macOS or Debian/Ubuntu
which chrome # probably /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
which chromium # probably /opt/homebrew/bin/chromium

# Windows
where chrome # probably C:\Program Files\Google\Chrome\Application\chrome.exe
```

Install and configure package
-----------------------------

[](#install-and-configure-package)

You can install the package via composer:

```
composer require backstage/laravel-og-image
```

Run the command to install the package:

```
php artisan og-image:install
```

You should also publish the views, to change the default layout of your Open Graph images:

```
php artisan vendor:publish --tag="og-image-views"
```

This is the content of the published config file (published at `config/og-image.php`):

```
