function ImageStyleRoutes::routes

Same name in other branches
  1. 9 core/modules/image/src/Routing/ImageStyleRoutes.php \Drupal\image\Routing\ImageStyleRoutes::routes()
  2. 8.9.x core/modules/image/src/Routing/ImageStyleRoutes.php \Drupal\image\Routing\ImageStyleRoutes::routes()
  3. 10 core/modules/image/src/Routing/ImageStyleRoutes.php \Drupal\image\Routing\ImageStyleRoutes::routes()

Returns an array of route objects.

Return value

\Symfony\Component\Routing\Route[] An array of route objects.

1 string reference to 'ImageStyleRoutes::routes'
image.routing.yml in core/modules/image/image.routing.yml
core/modules/image/image.routing.yml

File

core/modules/image/src/Routing/ImageStyleRoutes.php, line 47

Class

ImageStyleRoutes
Defines a route subscriber to register a URL for serving image styles.

Namespace

Drupal\image\Routing

Code

public function routes() {
    $routes = [];
    // Generate image derivatives of publicly available files. If clean URLs are
    // disabled image derivatives will always be served through the menu system.
    // If clean URLs are enabled and the image derivative already exists, PHP
    // will be bypassed.
    $directory_path = $this->streamWrapperManager
        ->getViaScheme('public')
        ->getDirectoryPath();
    $routes['image.style_public'] = new Route('/' . $directory_path . '/styles/{image_style}/{scheme}', [
        '_controller' => 'Drupal\\image\\Controller\\ImageStyleDownloadController::deliver',
        'required_derivative_scheme' => 'public',
    ], [
        '_access' => 'TRUE',
    ]);
    return $routes;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.