Download the PHP package abordage/laravel-og-images without Composer
On this page you can find all versions of the php package abordage/laravel-og-images. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download abordage/laravel-og-images
More information about abordage/laravel-og-images
Files in abordage/laravel-og-images
Package laravel-og-images
Short Description Generate Open Graph images (og:image, twitter:image, vk:image) for each site pages
License MIT
Homepage https://github.com/abordage/laravel-og-images
Informations about the package laravel-og-images
Open Graph Image Generator for Laravel
Create Open Graph images (og:image, twitter:image, vk:image) for each (or some) site pages.
Use page title to create an eye-catching page preview when users share the link on social networks or instant messengers. Learn more about Open Graph.
Features:
- Image generation with your text and site name
- Fully customizable (see configuration)
- Small image size (15-50 Kb) with high resolution and quality (check it)
- Aspect ratios presets for popular social networks
▶ See examples
Requirements
- PHP 7.4 - 8.3
- Laravel 8.x - 11.x
- The Imagick PHP extension
Installation
You can install the package via composer:
You can publish config file with:
Quick start
Note
All images are encoded inPNG
format as it provides the best ratio between size/quality. For the same reason, the package uses theImagick
driver - in tests, it showed an advantage in speed and final size of the generated images.
Usage
After generation, you need to somehow organize the relationship of images with a specific page (for example, attach to a model). If you already have a solution ready to accept an image and attach it to a specific page, you can get the image as a string instead of saving it:
If after generation you need to get sizes of the image, you can get it as follows:
Usage with spatie/laravel-medialibrary
spatie/laravel-medialibrary is a great package for associate all sorts of files with Eloquent models. If you are using this package (or similar), all you need to do is to add new collections to the model and attach images using media library.
Next, when creating a new page (or updating), generate an og-image and attach it:
Multiple images:
Now you can get the link for the og:image meta tag as follows:
Configuration
API Reference
Method | Returns | Added in | Changed in |
---|---|---|---|
make(string $text, string $preset = 'opengraph') |
self | 0.1.0 | 0.2.0 |
makeCustom(string $text, int $width, int $height) |
self | 0.2.0 | - |
get() |
string | 0.1.0 | - |
save(string $path) |
boolean | 0.1.0 | - |
getImageSizes() |
array | 0.3.0 | - |
Images aspect ratios
Preset | Aspect ratios | Docs |
---|---|---|
make(string $text) |
1200 x 630 (1.91:1) | |
make(string $text, 'opengraph') |
1200 x 630 (1.91:1) | |
make(string $text, 'facebook') |
1200 x 630 (1.91:1) | fb |
make(string $text, 'twitter') |
1200 x 600 (2:1) | |
make(string $text, 'vk') |
1200 x 536 (2.2:1) | vk |
Roadmap
Add ability to use gradients and images for the background.
Testing
Run all tests
or
or see https://github.com/abordage/laravel-og-images/actions/workflows/tests.yml
Feedback
Find a bug or have a feature request? Open an issue, or better yet, submit a pull request - contribution welcome!
Contributing
Please see CONTRIBUTING for details.
Credits
- Pavel Bychko (abordage)
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-og-images with dependencies
ext-imagick Version *
abordage/og-images Version ^0.4.1
illuminate/support Version ^8.0 || ^9.0 || ^10.0 || ^11.0