public function actionAddToGallery($modelPk, $imageName)
	{
		$img = new ImageGallery('create');
		$img->image_name = $imageName;
		$img->{Portfolio::getIdAttr()} = $modelPk;
		$img->makeThumb();
		$img->save();

		echo CJSON::encode(array('pk'=>$img->pk));
	}
Пример #2
0
 private function getGalleryImages($id, $edit = FALSE, $caption = NULL, $category = NULL)
 {
     try {
         $gal = new ImageGallery();
         $gal->max_dims = array(IMG_MAX_WIDTH, IMG_MAX_HEIGHT);
         // Maximum dimensions of the images (w, h)
         $gal->dir = GAL_SAVE_DIR . $this->url0 . $id . '/';
         $gal->imgCap_album = $id;
         $gal->imgTitle = $caption;
         $gal->relAttr = ' class="gal-disp"';
         $gal->getImages();
         // Read all images out of a folder
         if ($gal->checkSize() === FALSE) {
             $gal->preview = TRUE;
             $gal->max_dims = array(IMG_PREV_WIDTH, IMG_PREV_HEIGHT);
             // Maximum dimensions of the images (w, h)
             $gal->checkSize();
             // Make sure the images are the right size
         }
         $gal->makeThumb(IMG_THUMB_SIZE);
         // Creates thumb if they don't exist
         if ($edit) {
             return $gal->getImagesAsArray();
         } else {
             return $gal->getNumImages() > 0 ? $gal->displayGallery() : NULL;
         }
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }