Psr7Middlewares\Middleware\ImageTransformer::__construct PHP Method

__construct() public method

Define the available sizes, for example: [ 'small' => 'resizeCrop,50,50', 'medium' => 'resize,500', 'big' => 'resize,1000', ].
public __construct ( array $sizes )
$sizes array
    public function __construct(array $sizes)
    {
        foreach ($sizes as $prefix => $transform) {
            if (strpos($prefix, '/') === false) {
                $path = '';
            } else {
                $path = pathinfo($prefix, PATHINFO_DIRNAME);
                $prefix = pathinfo($prefix, PATHINFO_BASENAME);
            }
            if (!isset($this->sizes[$prefix])) {
                $this->sizes[$prefix] = [$path => $transform];
            } else {
                $this->sizes[$prefix][$path] = $transform;
            }
        }
    }