protected function FileDownloadController::webpResponse in WebP 8
Returns a WebP image as response.
Parameters
string $file: Path to image file.
array $headers: Response headers.
string $scheme: The file scheme, defaults to 'private'.
Return value
\Symfony\Component\HttpFoundation\BinaryFileResponse The transferred file as response.
1 call to FileDownloadController::webpResponse()
- FileDownloadController::download in src/
Controller/ FileDownloadController.php - Handles private file transfers.
File
- src/
Controller/ FileDownloadController.php, line 182
Class
Namespace
Drupal\webp\ControllerCode
protected function webpResponse($file, array $headers, $scheme) {
$headers += [
'Content-Type' => 'image/webp',
'Content-Length' => filesize($file),
];
// \Drupal\Core\EventSubscriber\FinishResponseSubscriber::onRespond()
// sets response as not cacheable if the Cache-Control header is not
// already modified. We pass in FALSE for non-private schemes for the
// $public parameter to make sure we don't change the headers.
return new BinaryFileResponse($file, 200, $headers, $scheme !== 'private');
}