public function saveImage() { $quality = isset($this->resize['quality']) ? $this->resize['quality'] : 100; $width = isset($this->resize['width']) ? $this->resize['width'] : null; $height = isset($this->resize['height']) ? $this->resize['height'] : null; $tmpName = $this->_newImage->tempName; $imageName = $this->_getImageName(); $image = Yii::app()->image->load($tmpName)->quality($quality); if (!($newFile = YFile::pathIsWritable($imageName, $image->ext, $this->uploadPath))) { throw new CHttpException(500, Yii::t('YupeModule.yupe', 'Directory "{dir}" is not acceptable for write!', array('{dir}' => $this->uploadPath))); } if ($width !== null && $image->width > $width || $height !== null && $image->height > $height) { $image->resize($width, $height); } if ($image->save($newFile)) { $this->owner->{$this->attributeName} = pathinfo($newFile, PATHINFO_BASENAME); } }