diff --git a/README.md b/README.md index c4a6dc4..c0391c8 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,17 @@ sudo xattr -rd com.apple.quarantine /Applications/Chromium.app # Remove quaranti ### On Debian/Ubuntu +For Ubuntu 22.04+ (Note: you'll need to update the environment variable of `CHROME_PATH` to `chomium-browser`) + +```bash +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 + ```bash # Install chromium from PPA instead of snap, because of permission issues with snapd version sudo add-apt-repository ppa:saiarcot895/chromium-dev -y diff --git a/src/OgImage.php b/src/OgImage.php index 097394c..58da91e 100644 --- a/src/OgImage.php +++ b/src/OgImage.php @@ -57,7 +57,7 @@ public function getStorageImageFilePath(string $signature): string public function getStorageImageFileExists(string $signature): bool { - if(config('og-image.debug') === true) { + if (config('og-image.debug') === true) { return false; } @@ -69,7 +69,9 @@ public function getStorageImageFileData(string $signature): ?string { return $this->getStorageDisk() ->get($this->getStorageImageFilePath($signature)); - } public function getStorageViewFileName(string $signature): string + } + + public function getStorageViewFileName(string $signature): string { return $signature.'.blade.php'; } @@ -132,19 +134,29 @@ public function getSignature(array|ComponentAttributeBag $parameters): string return $parameters['signature']; } - public function createImageFromParams(array $parameters): ?string + public function createImageFromParams(array $parameters, ?string $template = null, bool $returnImage = false): ?string { $signature = $this->getSignature($parameters); if (! OgImage::getStorageImageFileExists($signature)) { - $html = View::make('og-image::template', $parameters) - ->render(); + if (! empty($template) && View::exists($template)) { + $html = View::make($template, $parameters) + ->render(); + } else { + $html = View::make('og-image::template', $parameters) + ->render(); + } OgImage::saveImage($html, $signature); } - return Storage::disk(config('og-image.storage.disk')) - ->url(OgImage::getStorageImageFilePath($signature)); + if (! $returnImage) { + return Storage::disk(config('og-image.storage.disk')) + ->url(OgImage::getStorageImageFilePath($signature)); + } else { + return Storage::disk(config('og-image.storage.disk')) + ->get(OgImage::getStorageImageFilePath($signature)); + } } public function saveImage(string $html, string $filename): void @@ -196,7 +208,7 @@ public function getResponse(Request $request): Response ->render(); } - if($request->route()->getName() == 'og-image.html') { + if ($request->route()->getName() == 'og-image.html') { return response($html, 200, [ 'Content-Type' => 'text/html', ]);