Download the PHP package vormkracht10/laravel-open-graph-image without Composer
On this page you can find all versions of the php package vormkracht10/laravel-open-graph-image. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vormkracht10/laravel-open-graph-image
More information about vormkracht10/laravel-open-graph-image
Files in vormkracht10/laravel-open-graph-image
Package laravel-open-graph-image
Short Description A Laravel package to generate dynamic Open Graph images
License MIT
Homepage https://github.com/vormkracht10/laravel-open-graph-image
Informations about the package laravel-open-graph-image
Generate Dynamic Open Graph Images in Laravel
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
- Installation
- Usage
- Passing extra attributes
- Clearing cached images
- Changelog
- Contributing
- Security Vulnerabilities
- Credits
- License
Requirements
- PHP 8.1+
Installation
You can install the package via composer:
Run the command to install the package:
Then you should install puppeteer:
And make sure Puppeteer can find the correct node and npm versions on your computer or server. When it can't find node or npm, add the custom paths using these .env variables. You can use which node
and which npm
to find the correct paths to these binaries:
You should also publish the views, to change the design of your Open Graph Images:
This is the content of the published config file (published at config/open-graph-image.php
):
Usage
Just add this blade component into the head of your page.
If you don't want to use the blade component you can also use the facade or helper method to generate the url to the image.
When you share the page on any platform, the image will automatically be generated, cached and then shown in your post. The image from the default template will look like this:
This component uses the 'template' blade view by default. You can change this template to your needs. It is even possible to pass more attributes than the default ones. You can find the default template in the resources folder.
Passing extra attributes
Want to add more custom attributes to modify the button text for example? Simply pass them down to the blade component, facade or helper method:
You can now access the variable in the template.blade.php
by using the {{ $button }}
variable.
Generate image without using the blade component
When you need to generate the image without using the blade component, you can use the following method:
This will return the actual image from your configured storage. You can use this method to generate the image in your own controller for example.
Clearing cached images
All generated open graph images are cached by default. If you want to remove the cache, you can use the following command:
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
- Bas van Dinther
- Mark van Eijk
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-open-graph-image with dependencies
illuminate/contracts Version ^9.0|^10.0|^11.0
spatie/browsershot Version ^3.0|^4.0|^5.0
spatie/laravel-package-tools Version ^1.14