Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
markvaneijk committed Jan 11, 2024
1 parent 031c4b2 commit f942f7e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/Http/Controllers/LaravelOpenGraphImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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)
Expand All @@ -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);
}
}
Expand All @@ -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)
Expand All @@ -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(),
]);
}
}

0 comments on commit f942f7e

Please sign in to comment.