/**
  * Method to update images name/description via AJAX.
  * On success returns JSON array of objects with new image info.
  *
  * @param $imagesData
  *
  * @throws HttpException
  * @return string
  */
 public function actionChangeData($imagesData)
 {
     if (count($imagesData) == 0) {
         throw new HttpException(400, 'Nothing to save');
     }
     $images = $this->behavior->updateImagesData($imagesData);
     $resp = array();
     foreach ($images as $model) {
         $resp[] = array('id' => $model->id, 'rank' => $model->rank, 'name' => (string) $model->name, 'description' => (string) $model->description, 'preview' => $model->getUrl('preview'));
     }
     return Json::encode($resp);
 }
Example #2
1
 /**
  * Returns a list of behaviors that this component should behave as.
  *
  * @return array
  */
 public function behaviors()
 {
     return [TimestampBehavior::className(), 'galleryBehavior' => ['class' => GalleryBehavior::className(), 'type' => 'about', 'extension' => 'jpg', 'directory' => Yii::getAlias('@webroot') . '/uploads/about', 'url' => Yii::getAlias('@web') . '/uploads/about', 'versions' => ['medium' => function ($img) {
         /** @var Imagine\Image\ImageInterface $img */
         $dstSize = $img->getSize();
         $maxWidth = 800;
         if ($dstSize->getWidth() > $maxWidth) {
             $dstSize = $dstSize->widen($maxWidth);
         }
         return $img->copy()->resize($dstSize);
     }]]];
 }
Example #3
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [\app\components\NoDeleteBehavior::className(), self::GALLERY_IMAGE_BEHAVIOR => ['class' => \zxbodya\yii2\galleryManager\GalleryBehavior::className(), 'tableName' => '{{%product_image}}', 'type' => self::GALLERY_IMAGE_TYPE, 'extension' => 'jpg', 'directory' => Yii::getAlias('@webroot/images/product/'), 'url' => Yii::getAlias('@web/images/product/'), 'timeHash' => false, 'versions' => ['small' => function ($img) {
         /** @var \Imagine\Image\ImageInterface $img */
         return $img->copy()->thumbnail(new \Imagine\Image\Box(200, 200));
     }, 'medium' => function ($img) {
         /** @var Imagine\Image\ImageInterface $img */
         $dstSize = $img->getSize();
         $maxWidth = 800;
         if ($dstSize->getWidth() > $maxWidth) {
             $dstSize = $dstSize->widen($maxWidth);
         }
         return $img->copy()->resize($dstSize);
     }]]];
 }
Example #4
0
 public function behaviors()
 {
     return ['galleryBehavior' => ['class' => GalleryBehavior::className(), 'type' => 'gallery', 'extension' => 'jpg', 'directory' => Yii::getAlias('@webroot') . '/images/product/gallery', 'url' => Yii::getAlias('@web') . '/images/product/gallery', 'versions' => ['small' => function ($img) {
         /** @var \Imagine\Image\ImageInterface $img */
         return $img->copy()->thumbnail(new \Imagine\Image\Box(200, 200));
     }, 'medium' => function ($img) {
         /** @var \Imagine\Image\ImageInterface $img */
         $dstSize = $img->getSize();
         $maxWidth = 800;
         if ($dstSize->getWidth() > $maxWidth) {
             $dstSize = $dstSize->widen($maxWidth);
         }
         return $img->copy()->resize($dstSize);
     }]]];
 }
Example #5
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ['dt' => ['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'created_date', 'updatedAtAttribute' => 'updated_date', 'value' => new Expression('NOW()')], 'us' => ['class' => BlameableBehavior::className(), 'createdByAttribute' => 'created_user', 'updatedByAttribute' => 'updated_user'], 'galleryBehavior' => ['class' => GalleryBehavior::className(), 'type' => 'posts', 'extension' => 'jpg', 'directory' => Yii::getAlias('@webroot') . '/images/posts/gallery', 'url' => Yii::getAlias('@web') . '/images/posts/gallery', 'versions' => ['small' => function ($img) {
         /** @var \Imagine\Image\ImageInterface $img */
         return $img->copy()->thumbnail(new \Imagine\Image\Box(200, 200));
     }, 'medium' => function ($img) {
         /** @var Imagine\Image\ImageInterface $img */
         $dstSize = $img->getSize();
         $maxWidth = 800;
         if ($dstSize->getWidth() > $maxWidth) {
             $dstSize = $dstSize->widen($maxWidth);
         }
         return $img->copy()->resize($dstSize);
     }]]];
 }
Example #6
0
 public function behaviors()
 {
     //        ini_set('memory_limit', '64M');
     return [['class' => Taggable::className()], Taggable::className(), TimestampBehavior::className(), 'galleryBehavior' => ['class' => GalleryBehavior::className(), 'type' => 'objreservation', 'extension' => 'jpg', 'directory' => Yii::getAlias('@root') . '/images/product/gallery', 'url' => '/images/product/gallery', 'versions' => ['small' => function ($img) {
         /** @var ImageInterface $img */
         return $img->copy()->thumbnail(new Box(100, 100));
     }, 'medium' => function ($img) {
         /** @var ImageInterface $img */
         $dstSize = $img->getSize();
         $maxWidth = 480;
         if ($dstSize->getWidth() > $maxWidth) {
             $dstSize = $dstSize->widen($maxWidth);
         }
         return $img->copy()->resize($dstSize);
     }]]];
 }
Example #7
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [TimestampBehavior::className(), SaveUserRole::className(), 'uploadFile' => ['class' => UploadBehaviour::className(), 'fields' => ['image'], 'allowedFileExtentions' => ['png', 'jpg']], 'multipleUploadFile' => ['class' => UploadBehaviour::className(), 'fields' => ['file_collection_id'], 'allowedFileExtentions' => ['png', 'jpg'], 'multiple' => true], 'galleryBehavior' => ['class' => GalleryBehavior::className(), 'type' => 'user', 'extension' => 'jpg', 'directory' => Yii::getAlias('@webroot') . '/files/User/gallery', 'url' => Yii::getAlias('@web') . '/files/User/gallery']];
 }
Example #8
0
 public function behaviors()
 {
     return ['galleryBehavior' => ['class' => GalleryBehavior::className(), 'type' => 'product', 'extension' => 'jpg', 'directory' => Yii::getAlias('@webroot') . '/img/exclusives', 'url' => Yii::getAlias('@web') . '/img/exclusives', 'hasName' => false, 'hasDescription' => false, 'versions' => []]];
 }