Search
Social Media Image Kit

Social Media Image Kit

Configuring Browsershot

Browsershot provides many configuration values that can be adjusted, based on your system's specific setup. More information about all of these options can be found within their official documentation at https://spatie.be/docs/browsershot/v2/introduction.

#Changing Browsershot Instance Settings

If you need to customize the Browsershot instance that is used when generating social media images, this can be done by using the SocialMediaImageKit facade's configureBrowsershot method.

The configureBrowsershot method accepts a callback function that will receive the Browsershot instance before images are generated. When using this customization option, you should not update the image type or the size of the image.

As an example, we might configure the Browsershot similar to the following when running on a Windows system:

1<?php
2 
3namespace App\Providers;
4 
5use Illuminate\Support\ServiceProvider;
6use Stillat\SocialMediaImageKit\Support\Facades\SocialMediaImageKit;
7 
8class AppServiceProvider extends ServiceProvider
9{
10 /**
11 * Bootstrap any application services.
12 */
13 public function boot(): void
14 {
15 SocialMediaImageKit::configureBrowsershot(function (Browsershot $browsershot) {
16 $browsershot->setCustomTempPath('C:/chromedata/tmp')
17 ->setUserDataDir('C:/chromedata')
18 ->setNodeBinary('C:/Program Files/nodejs/node.exe')
19 ->waitUntilNetworkIdle()
20 ->newHeadless()
21 ->noSandbox();
22 });
23 }
24}

Some absolutely amazing
people

The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.