public function getImage($lang = null) { if (empty($lang)) { $lang = Yii::$app->language; } return ImageManager::removeFolderStr(ImageManager::getBannerImage($this->id, $lang)); }
public function upload($id) { if ($this->validate()) { if (!is_null($this->listFile)) { ImageManager::delProductImages($id, 'list'); ImageManager::addProductImage($id, 'list', $this->listFile); } if (!is_null($this->detailFile)) { ImageManager::addProductImage($id, 'det', $this->detailFile); } return true; } else { return false; } }
/** * Updates an existing Banner model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { foreach (Property::getLanguages() as $lang) { $file = UploadedFile::getInstanceByName('image_' . $lang); if (!is_null($file)) { ImageManager::addBannerImage($model->id, $file, $lang); } } return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model]); } }
public function actionImageDelete($id) { $name = isset($_REQUEST['name']) ? $_REQUEST['name'] : ''; if (!empty($name)) { ImageManager::deleteProductImage($name); } return $this->redirect(['update', 'id' => $id, 'panel' => 'images']); }
public function getDetailImages() { return ImageManager::removeFolder(ImageManager::getProductImages($this->id, ImageManager::PRODUCT_DETAIL)); }