/** * Create images for this article. */ public function createImage() { $thumb = Yii::app()->phpThumb->create($this->image->getTempName()); $thumb->resize(600, 600); $path = Yii::app()->params['projectPath'] . Yii::app()->params['imagePath']; $thumb->save($path . $this->imageName . '.jpg', 'jpg'); // Add this image to the db. $pic = new Photo(); $pic->Name = $this->imageName . '.jpg'; if ($pic->save()) { // Create new linker. $picLinker = new PlantLeafPhoto(); $picLinker->PlantLeafId = $this->Id; $picLinker->PhotoId = $pic->Id; $picLinker->save(); } }
/** * Method for deleting media assigned to this */ public function actionDelmedia($id) { $model = PlantLeafPhoto::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } $model->delete(); }