Exemple #1
0
 public function getThumb($width, $height)
 {
     $path = Yii::getPathOfAlias($this->path);
     $filePath = $path . DIRECTORY_SEPARATOR . 'thumb_' . $width . 'x' . $height . "_" . $this->name;
     $fileName = 'thumb_' . $width . 'x' . $height . "_" . $this->name;
     if (file_exists($filePath)) {
         return $fileName;
     } else {
         $image = new CImageHandler();
         if ($image->load($path . DIRECTORY_SEPARATOR . $this->name)) {
             $image->adaptiveThumb($width, $height)->save($filePath);
             return $fileName;
         } else {
             return null;
         }
     }
 }
Exemple #2
0
 public static function createThumb($image, $width, $height)
 {
     $newPath = self::returnModifiedThumbPath($image, $width, $height);
     $originalPath = self::returnOrigPath($image);
     if (!file_exists($originalPath)) {
         return '';
     }
     $thumb = new CImageHandler();
     if ($thumb->load($originalPath)) {
         /*$thumb->thumb($width, $height, self::KEEP_THUMB_PROPORTIONAL)->save($newPath);*/
         $thumb->adaptiveThumb($width, $height)->save($newPath);
         return self::returnThumbUrl($image, $width, $height);
     } else {
         return '';
     }
 }