/** * Render image items * @return string */ protected function renderItems() { $items = ''; foreach ($this->getItems() as $item) { $items .= Item::widget(['fileKey' => $this->_fileKey, 'thumbKey' => $this->_thumbKey, 'file' => $this->getItemFile($item), 'thumb' => $this->getItemThumb($item), 'width' => $this->width, 'height' => $this->height, 'thumbWidth' => $this->thumbWidth, 'thumbHeight' => $this->thumbHeight, 'maxImageWidth' => $this->maxImageWidth, 'maxImageHeight' => $this->maxImageHeight, 'baseName' => $this->getItemBaseName($item), 'data' => $this->getItemData($item), 'buttons' => $this->getItemButtons($item), 'quality' => $this->quality, 'uploadPath' => $this->uploadPath, 'baseRoute' => $this->_baseRoute]); } return $items; }
/** * Uploading file and render image item. * @param array $settings Widget settings. * @param UploadedFile $file File to upload. * @return string Rendered image item. */ private function upload($settings, UploadedFile $file) { $name = UploadImageHelper::save($file, $settings['maxImageWidth'], $settings['maxImageHeight'], $settings['quality']); $thumb = null; if ($settings['thumbKey'] !== null) { $thumb = UploadImageHelper::thumb($name, $settings['thumbWidth'], $settings['thumbHeight'], $settings['quality']); } return Item::widget(['fileKey' => $settings['fileKey'], 'thumbKey' => $settings['thumbKey'], 'file' => $name, 'thumb' => $thumb, 'width' => $settings['width'], 'height' => $settings['height'], 'thumbWidth' => $settings['thumbWidth'], 'thumbHeight' => $settings['thumbHeight'], 'maxImageWidth' => $settings['maxImageWidth'], 'maxImageHeight' => $settings['maxImageHeight'], 'baseName' => $settings['baseName'], 'data' => $settings['data'], 'quality' => $settings['quality'], 'uploadPath' => $settings['uploadPath'], 'buttons' => $settings['buttons']]); }