1.3.0

OG Image Generator

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


Laravel package to automatically create a og image that the page generates when it's saved to social media.

Installation

You can install the package via composer:

composer require paulund/og-image-generator
npm install puppeteer
php artisan vendor:publish --provider="Paulund\OgImageGenerator\OgImageGeneratorServiceProvider"

In the <head></head> tag of your application you need to add the meta og-image tag. Pointing to the route created by the package and passing in a variable of $ogTitle which is the text that will appear on the generated image.

<meta property="og:image" content="{{ route('og-image', ['title' => $ogTitle ]) }}" />

Configuration

There is no configuration required for this package. The package will automatically start generating Open Graph images for social media sharing.

But you can configure the package by publishing the config file, which will allow you to change the following configs.

  • Image mime type - default is png
  • Storage disk - default is local
  • Storage path - default is public/og-images

Config Styling

By default OG Image Generator comes with tailwinds css installed on the page and you can customise the styling of the image by changing the tailwind classes in the config file.

'styling' => [
    'background' => 'bg-gray-900',
    'text' => 'text-white',
],

Customise The View

If you'd like you use your own blade view file then you can change the view config in the config file.

'view' => env('OG_IMAGE_GENERATOR_VIEW', 'paulund/og-image-generator::image'),

Or you can change the view in the .env file.

OG_IMAGE_GENERATOR_VIEW=your-view-file

Delete Old Images

There is a command that you can run to delete all the old images that have been created by the package.

php artisan og-image:delete-old-images

This command will delete all the images that are older than 90 days.

This command is added to the Laravel scheduler to run every day.

Testing

vendor/bin/testbench workbench:install
composer check

Credits

License

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

Tutorial

To learn more about how this work you can read the tutorial on Paulund

Change Log

1.3.0

1.2.0

1.1.0

1.0.1

1.0.0

UpChecker

Reliable uptime monitoring and instant alerts for any website downtime.

  • Uptime Monitoring
  • Performance Monitoring
  • SSL Certificate Alerts
  • Domain Monitoring
  • DNS Checker
  • XML Sitemap Monitoring