Loading src/Controller/ImageStyleDownloadController.php +14 −1 Changes for src/Controller/ImageStyleDownloadController.php: 14 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Drupal\imageapi_optimize_webp\Controller; use Drupal\Core\Site\Settings; use Drupal\image\Controller\ImageStyleDownloadController as CoreImageStyleDownloadController; use Drupal\image\ImageStyleInterface; use Symfony\Component\HttpFoundation\BinaryFileResponse; Loading Loading @@ -59,7 +60,19 @@ class ImageStyleDownloadController extends CoreImageStyleDownloadController { 'Content-Type' => 'image/webp', 'Content-Length' => $image->getFileSize(), ]; return new BinaryFileResponse($uri, 200, $headers, $scheme !== 'private'); // Only the public scheme and schemes opted into the // file_additional_public_schemes setting may be marked publicly // cacheable; all other schemes are access controlled. $additional_public_schemes = array_diff( Settings::get('file_additional_public_schemes', []), ['public', 'private', 'temporary'], ); $is_public = in_array( $this->streamWrapperManager->getScheme($derivative_uri), array_merge(['public'], $additional_public_schemes), TRUE, ); return new BinaryFileResponse($uri, 200, $headers, $is_public); } // If the derivative does not exist, return a failed reponse. return new Response($this->t('Error generating image.'), 500); Loading Loading
src/Controller/ImageStyleDownloadController.php +14 −1 Changes for src/Controller/ImageStyleDownloadController.php: 14 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Drupal\imageapi_optimize_webp\Controller; use Drupal\Core\Site\Settings; use Drupal\image\Controller\ImageStyleDownloadController as CoreImageStyleDownloadController; use Drupal\image\ImageStyleInterface; use Symfony\Component\HttpFoundation\BinaryFileResponse; Loading Loading @@ -59,7 +60,19 @@ class ImageStyleDownloadController extends CoreImageStyleDownloadController { 'Content-Type' => 'image/webp', 'Content-Length' => $image->getFileSize(), ]; return new BinaryFileResponse($uri, 200, $headers, $scheme !== 'private'); // Only the public scheme and schemes opted into the // file_additional_public_schemes setting may be marked publicly // cacheable; all other schemes are access controlled. $additional_public_schemes = array_diff( Settings::get('file_additional_public_schemes', []), ['public', 'private', 'temporary'], ); $is_public = in_array( $this->streamWrapperManager->getScheme($derivative_uri), array_merge(['public'], $additional_public_schemes), TRUE, ); return new BinaryFileResponse($uri, 200, $headers, $is_public); } // If the derivative does not exist, return a failed reponse. return new Response($this->t('Error generating image.'), 500); Loading