src/Creation/ImageItemFactory.php
public function createImage(OwnField $field, array $data, $cap = false)
    {
        $imageType = $field->getFieldType();

        if($imageType->getName() !== 'image')
        {
            throw new ImageAggrException('Попытка картинки для поля не картинки ('.$imageType->getName().')!');
        }

        $fields  = $this->collectionFactory->createFieldsCollection();
        $owns    = $this->collectionFactory->createOwnsCollection();
        $refs    = $this->collectionFactory->createRefsCollection();

        $resizes = new ResizesCollection($field, $this->capGenerator);
        $crops = new CropsCollection($field, $this->capGenerator);

        $imageItem = new ImageItem($field, $fields, $owns, $refs, $resizes, $crops, $cap);

        $resizes->setOriginal($imageItem);
        $crops->setOriginal($imageItem);


        $metaName       = $imageType->getOwn('name');
        $metaLink       = $imageType->getOwn('link');
        $metaAlt        = $imageType->getOwn('alt');
        $metaCacheIndex = $imageType->getOwn('cache_index');
        $metaWidth      = $imageType->getOwn('width');
        $metaHeight     = $imageType->getOwn('height');

        $fieldName       = $this->createLocalCField($imageItem, $metaName,       $this->checkAndGetData($data, 'name', 'string'));
        $fieldLink       = $this->createLocalCField($imageItem, $metaLink,       $this->checkAndGetData($data, 'link', 'string'));
        $fieldAlt        = $this->createLocalCField($imageItem, $metaAlt,        $this->checkAndGetData($data, 'alt', 'string'));
        $fieldCacheIndex = $this->createLocalCField($imageItem, $metaCacheIndex, $this->checkAndGetData($data, 'cache_index', 'integer'));
        $fieldWidth      = $this->createLocalCField($imageItem, $metaWidth,      $this->checkAndGetData($data, 'width', 'integer'));
        $fieldHeight     = $this->createLocalCField($imageItem, $metaHeight,     $this->checkAndGetData($data, 'height', 'integer'));

        //Собственные поля
        $imageItem->setOwn($fieldName);   $imageItem->setField($fieldName);
        $imageItem->setOwn($fieldLink);   $imageItem->setField($fieldLink);
        $imageItem->setOwn($fieldAlt);    $imageItem->setField($fieldAlt);
        $imageItem->setOwn($fieldCacheIndex); $imageItem->setField($fieldCacheIndex);
        $imageItem->setOwn($fieldWidth);  $imageItem->setField($fieldWidth);
        $imageItem->setOwn($fieldHeight); $imageItem->setField($fieldHeight);

        return $imageItem;
    }
public function createImage(OwnField $field, array $data, $cap = false)
    {
        $imageType = $field->getFieldType();

        if($imageType->getName() !== 'image')
        {
            throw new ImageAggrException('Попытка картинки для поля не картинки ('.$imageType->getName().')!');
        }

        $fields  = $this->collectionFactory->createFieldsCollection();
        $owns    = $this->collectionFactory->createOwnsCollection();
        $refs    = $this->collectionFactory->createRefsCollection();

        $resizes = new ResizesCollection($field, $this->capGenerator);
        $crops = new CropsCollection($field, $this->capGenerator);

        $imageItem = new ImageItem($field, $fields, $owns, $refs, $resizes, $crops, $cap);

        $resizes->setOriginal($imageItem);
        $crops->setOriginal($imageItem);


        $metaName       = $imageType->getOwn('name');
        $metaLink       = $imageType->getOwn('link');
        $metaAlt        = $imageType->getOwn('alt');
        $metaCacheIndex = $imageType->getOwn('cache_index');
        $metaWidth      = $imageType->getOwn('width');
        $metaHeight     = $imageType->getOwn('height');

        $fieldName       = $this->createLocalCField($imageItem, $metaName,       $this->checkAndGetData($data, 'name', 'string'));
        $fieldLink       = $this->createLocalCField($imageItem, $metaLink,       $this->checkAndGetData($data, 'link', 'string'));
        $fieldAlt        = $this->createLocalCField($imageItem, $metaAlt,        $this->checkAndGetData($data, 'alt', 'string'));
        $fieldCacheIndex = $this->createLocalCField($imageItem, $metaCacheIndex, $this->checkAndGetData($data, 'cache_index', 'integer'));
        $fieldWidth      = $this->createLocalCField($imageItem, $metaWidth,      $this->checkAndGetData($data, 'width', 'integer'));
        $fieldHeight     = $this->createLocalCField($imageItem, $metaHeight,     $this->checkAndGetData($data, 'height', 'integer'));

        //Собственные поля
        $imageItem->setOwn($fieldName);   $imageItem->setField($fieldName);
        $imageItem->setOwn($fieldLink);   $imageItem->setField($fieldLink);
        $imageItem->setOwn($fieldAlt);    $imageItem->setField($fieldAlt);
        $imageItem->setOwn($fieldCacheIndex); $imageItem->setField($fieldCacheIndex);
        $imageItem->setOwn($fieldWidth);  $imageItem->setField($fieldWidth);
        $imageItem->setOwn($fieldHeight); $imageItem->setField($fieldHeight);

        return $imageItem;
    }
@param \Interpro\Core\Contracts\Taxonomy\Fields\OwnField $field
@param array $data
@param bool $cap

@return \Interpro\ImageAggr\Items\ImageItem