protected function ImageStyleDownloadController::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 ImageStyleDownloadController::webpResponse()
- ImageStyleDownloadController::deliver in src/
Controller/ ImageStyleDownloadController.php - Generates a derivative, given a style and image path.
File
- src/
Controller/ ImageStyleDownloadController.php, line 231
Class
- ImageStyleDownloadController
- Defines a controller to serve image styles.
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');
}