Contao\CoreBundle\Image\ImageFactoryInterface::getImportantPartFromLegacyMode PHP Метод

getImportantPartFromLegacyMode() публичный Метод

Returns the equivalent important part from a legacy resize mode.
public getImportantPartFromLegacyMode ( Contao\Image\ImageInterface $image, string $mode ) : Contao\Image\ImportantPartInterface
$image Contao\Image\ImageInterface
$mode string One of left_top, center_top, right_top, left_center, center_center, right_center, left_bottom, center_bottom, right_bottom
Результат Contao\Image\ImportantPartInterface
    public function getImportantPartFromLegacyMode(ImageInterface $image, $mode);

Usage Example

Пример #1
0
 /**
  * {@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;
 }