/**
* {@inheritdoc}
*/
public function create($path, $size = null)
{
$attributes = [];
if ($path instanceof ImageInterface) {
$image = $path;
} else {
$image = $this->imageFactory->create($path);
}
if (is_array($size) && isset($size[2]) && 1 === substr_count($size[2], '_')) {
$image->setImportantPart($this->imageFactory->getImportantPartFromLegacyMode($image, $size[2]));
$size[2] = ResizeConfigurationInterface::MODE_CROP;
}
if ($size instanceof PictureConfigurationInterface) {
$config = $size;
} else {
list($config, $attributes) = $this->createConfig($size);
}
$picture = $this->pictureGenerator->generate($image, $config, (new ResizeOptions())->setImagineOptions($this->imagineOptions)->setBypassCache($this->bypassCache));
$picture = $this->addImageAttributes($picture, $attributes);
return $picture;
}