From f942f7ebb0ee98e5e9cfbec0d14b7e82ec076aef Mon Sep 17 00:00:00 2001 From: Mark van Eijk Date: Thu, 11 Jan 2024 12:50:28 +0100 Subject: [PATCH] wip --- .../LaravelOpenGraphImageController.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Http/Controllers/LaravelOpenGraphImageController.php b/src/Http/Controllers/LaravelOpenGraphImageController.php index 7e6ff42..e374002 100644 --- a/src/Http/Controllers/LaravelOpenGraphImageController.php +++ b/src/Http/Controllers/LaravelOpenGraphImageController.php @@ -37,7 +37,7 @@ public function __construct() public function __invoke(Request $request) { - if (! app()->environment('local') && ! $request->hasValidSignature()) { + if (!app()->environment('local') && !$request->hasValidSignature()) { abort(403); } @@ -48,7 +48,7 @@ public function __invoke(Request $request) return $html; } - if (! $this->getStorageFileExists($request->signature)) { + if (!$this->getStorageFileExists($request->signature)) { $this->saveOpenGraphImage($html, $request->signature); } @@ -67,12 +67,12 @@ public function getStoragePath() public function getStorageFileName($signature) { - return $signature.'.'.$this->imageExtension; + return $signature . '.' . $this->imageExtension; } public function getStorageFilePath($filename) { - return $this->getStoragePath().'/'.$this->getStorageFileName($filename); + return $this->getStoragePath() . '/' . $this->getStorageFileName($filename); } public function getStorageFileData($filename) @@ -97,7 +97,7 @@ public function getImageType() public function ensureDirectoryExists() { - if (! File::isDirectory($this->getStoragePath())) { + if (!File::isDirectory($this->getStoragePath())) { File::makeDirectory($this->getStoragePath(), 0777, true); } } @@ -108,18 +108,18 @@ public function getScreenshot($html, $filename) ->noSandbox() ->showBackground() ->windowSize($this->imageWidth, $this->imageHeight) - ->setScreenshotType($this->getImageType(), $this->imageQuality) - ->screenshot($this->getStorageFilePath($filename)); + ->setScreenshotType($this->getImageType(), $this->imageQuality); - if(config('open-graph-image.paths.node')) { + if (config('open-graph-image.paths.node')) { $browsershot = $browsershot->setNodeBinary(config('open-graph-image.paths.node')); } - - if(config('open-graph-image.paths.npm')) { + + if (config('open-graph-image.paths.npm')) { $browsershot = $browsershot->setNpmBinary(config('open-graph-image.paths.npm')); } - return $browsershot; + return $browsershot + ->screenshot($this->getStorageFilePath($filename)); } public function saveOpenGraphImage($html, $filename) @@ -135,7 +135,7 @@ public function saveOpenGraphImage($html, $filename) public function getOpenGraphImageResponse($filename) { return response($this->getStorageFileData($filename), 200, [ - 'Content-Type' => 'image/'.$this->getImageType(), + 'Content-Type' => 'image/' . $this->getImageType(), ]); } }