From 9305556c1c2fd77e9f65c42e3600380491e48a42 Mon Sep 17 00:00:00 2001 From: ncla Date: Sat, 11 Feb 2023 20:18:27 +0200 Subject: [PATCH] Rethrow `Unable to read file` exception for placeholder generation in SSG context (#209) Workaround: https://github.com/spatie/statamic-responsive-images/issues/178#issuecomment-1310963543 --- src/Breakpoint.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Breakpoint.php b/src/Breakpoint.php index 41f5a3f..45a3470 100644 --- a/src/Breakpoint.php +++ b/src/Breakpoint.php @@ -4,7 +4,9 @@ use Exception; use Illuminate\Contracts\Support\Arrayable; +use Illuminate\Support\Arr; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Config; use League\Flysystem\FilesystemException; use Statamic\Contracts\Assets\Asset; @@ -288,7 +290,10 @@ private function readImageToBase64($assetPath): string|null $assetContent = $cache->read($assetPath); $assetMimeType = $cache->mimeType($assetPath); } catch (FilesystemException $e) { - if (config('app.debug')) { + $isSsgRunning = App::runningInConsole() && + Str::startsWith(Arr::get(request()->server(), 'argv.1'), ['statamic:ssg:generate', 'ssg:generate']); + + if (config('app.debug') || $isSsgRunning) { throw $e; }