Inheritance: extends CActiveRecordBehavio\CActiveRecordBehavior
Ejemplo n.º 1
0
 public function saveFile()
 {
     if (!$this->resizeOnUpload) {
         parent::saveFile();
         return;
     }
     $newFileName = $this->getFileName();
     $path = Yii::app()->uploadManager->getFilePath($newFileName, $this->getUploadPath());
     if (!YFile::checkPath(pathinfo($path, PATHINFO_DIRNAME))) {
         throw new \CHttpException(500, Yii::t('YupeModule.yupe', 'Directory "{dir}" is not acceptable for write!', array('{dir}' => $path)));
     }
     /*
             $image = Imagine::resize(
        $this->_currentFile->getTempName(),
        $this->resizeOptions['width'],
        $this->resizeOptions['height']
             );
     
             $image->save(
        $path,
        $this->resizeOptions['quality']
             );
     * 
     */
     $image = Yii::app()->image->load($this->_currentFile->getTempName())->quality($this->resizeOptions['quality']);
     $image->resize($this->resizeOptions['width'], $this->resizeOptions['height'], $this->resizeOptions['master']);
     $image->save($path);
     $this->getOwner()->{$this->attributeName} = $newFileName;
     $this->_prevFile = $this->getPrevFile();
 }
Ejemplo n.º 2
0
 /**
  * @throws \CException
  */
 public function saveFile()
 {
     if (!$this->resizeOnUpload) {
         return parent::saveFile();
     }
     $newFileName = $this->generateFilename();
     $path = $this->uploadManager->getFilePath($newFileName, $this->getUploadPath());
     if (!YFile::checkPath(pathinfo($path, PATHINFO_DIRNAME))) {
         throw new \CException(Yii::t('YupeModule.yupe', 'Directory "{dir}" is not acceptable for write!', ['{dir}' => $path]));
     }
     Imagine::resize($this->getUploadedFileInstance()->getTempName(), $this->resizeOptions['width'], $this->resizeOptions['height'])->save($path, $this->resizeOptions['quality']);
     $this->getOwner()->setAttribute($this->attributeName, $newFileName);
 }
 /**
  *
  */
 protected function removeFile()
 {
     $this->removeThumbs();
     parent::removeFile();
 }