RouteSubscriber.php in ImageAPI Optimize WebP 2.x
File
src/Routing/RouteSubscriber.php
View source
<?php
namespace Drupal\imageapi_optimize_webp\Routing;
use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;
class RouteSubscriber extends RouteSubscriberBase {
protected function alterRoutes(RouteCollection $collection) {
if ($route = $collection
->get('image.style_public')) {
$route
->setDefault('_controller', 'Drupal\\imageapi_optimize_webp\\Controller\\ImageStyleDownloadController::deliver');
}
if ($route = $collection
->get('image.style_private')) {
$route
->setDefault('_controller', 'Drupal\\imageapi_optimize_webp\\Controller\\ImageStyleDownloadController::deliver');
}
}
}