Problem/Motivation
I have tried to use this module on a site that is using s3fs. The public files are on a s3 bucket. I can not see the derivatives images being generated on s3 nor loaded in the browser, No logs or messages are reported neither.
Browsing into the code I can see that webp is doing an altering of some routes, like image.style_public, in order to set his own controller. https://git.drupalcode.org/project/webp/-/blob/8.x-1.x/src/Routing/Route...
S3FS has his own controller to manage image styles that are being stored in s3 https://git.drupalcode.org/project/s3fs/-/blob/8.x-3.x/src/Routing/S3fsI...
I think webp needs to be able to manage the s3fs controller for derivatives images as well. Otherwise no derivatives images will be generated on the s3 bucket.
Steps to reproduce
- Install s3fs module
- Configure the module to send public files to the bucket (nothing locally).
- Install webp, set the styles as the documentation
- The webp images will not be created in the bucket, the images will not be show in the browser, no warnings nor messages are reported.
Proposed resolution
As a simple experiment I have tried to do the same alter for the route of the s3fs module and everything seems to work.
/**
* Class RouteSubscriber.
*
* Listens to the dynamic route events.
*/
class RouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
foreach (['image.style_public', 'image.style_private'] as $route_id) {
if ($route = $collection->get($route_id)) {
$route->setDefault('_controller', 'Drupal\webp\Controller\ImageStyleDownloadController::deliver');
}
}
foreach (['system.private_file_download', 'system.files'] as $route_id) {
if ($route = $collection->get($route_id)) {
$route->setDefault('_controller', 'Drupal\webp\Controller\FileDownloadController::download');
}
}
if ($route = $collection->get('s3fs.image_styles')) {
$route->setDefault('_controller', 'Drupal\webp\Controller\ImageStyleDownloadController::deliver');
}
}
}
Maybe this is something that can work to solve the issue.
Remaining tasks
Will be nice to add in the docuemntation of the module that s3fs integration is not functional, so other developers wont waste time trying to use this module until it works well.