Пример #1
0
 /**
  * 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 TuberPhoto();
         $picLinker->TuberId = $this->Id;
         $picLinker->PhotoId = $pic->Id;
         $picLinker->save();
     }
 }
Пример #2
0
 /**
  * Method for deleting media assigned to this
  */
 public function actionDelmedia($id)
 {
     $model = TuberPhoto::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $model->delete();
 }