protected function ImageStyleDownloadController::response in WebP 8
Returns an image style derivative as response.
Parameters
\Drupal\Core\Image\Image $image: The image style derivation.
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::response()
- ImageStyleDownloadController::deliver in src/
Controller/ ImageStyleDownloadController.php - Generates a derivative, given a style and image path.
File
- src/
Controller/ ImageStyleDownloadController.php, line 256
Class
- ImageStyleDownloadController
- Defines a controller to serve image styles.
Namespace
Drupal\webp\ControllerCode
protected function response(Image $image, array $headers, $scheme) {
$headers += [
'Content-Type' => $image
->getMimeType(),
'Content-Length' => $image
->getFileSize(),
];
// \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($image
->getSource(), 200, $headers, $scheme !== 'private');
}