with(['pressRelease' => fn ($query) => $query ->withoutGlobalScope(PortalScope::class) ->with(['company' => fn ($company) => $company->withoutGlobalScope(PortalScope::class)])]) ->findOrFail($image); $pressRelease = $image->pressRelease; abort_unless($pressRelease instanceof PressRelease, 404); // Dieselbe Freigaberegel wie Seitenabfragen und OG-Auswahl (Audit // N01): ein zurückgehaltenes oder noch unbestätigtes v2-Bild ist über // die Direktadresse nicht öffentlich, sondern nur mit Signatur oder // `view`-Recht (Vorschau, Konto, Admin) und ohne öffentlichen Cache. $isPublic = $this->pressReleaseMediaIsPublic($pressRelease) && $image->isPubliclyDeliverable(); $this->authorizePressReleaseMediaAccess($request, $pressRelease, $isPublic); $path = $image->pathForVariant($variant); abort_unless(is_string($path) && filled($path), 404); return Storage::disk($image->disk)->response($path, headers: [ 'Cache-Control' => $this->mediaCacheControl($isPublic), 'X-Content-Type-Options' => 'nosniff', ]); } }