dev-master
9999999-dev https://github.com/xtracode/yii2-imageYii2 image module
The Requires
- php >=5.3.0
- yiisoft/yii2 *
- yiisoft/yii2-imagine ~2.0.0
- bupy7/yii2-widget-cropbox 3.*
- newerton/yii2-fancybox dev-master
extension yii2 widget image
Yii2 image module
Yii2 module for image manipulating., (*2)
Documentation is at docs/guide/README.md., (*3)
The preferred way to install this extension is through composer., (*4)
Either run, (*5)
php composer.phar require "xtracode/yii2-image" "dev-master"
or add, (*6)
"xtracode/yii2-image" : "dev-master"
to the require section of your application's composer.json
file., (*7)
'modules' => [ 'image' => [ 'class' => 'xtracode\yii2-image\ImageModule' ] ]
php yii migrate --migrationPath=@xtracode/yii2-image/migrations
public function actions() { return [ 'delete-image' => [ 'class' => '\xtracode\image\actions\DeleteImageAction', ], 'main-image' => [ 'class' => '\xtracode\image\actions\MainImageAction', ], ]; }
Use method $model->uploadSingleImage() in controller:, (*8)
public function actionCreate() { $model = new Article; if ($model->load($_POST) && $model->save()) { $model->uploadImage(); \Yii::$app->session->setFlash('success', \Yii::t('article', 'Article successfully saved')); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', [ 'model' => $model, ]); } }
In view:, (*9)
<div class="col-sm-offset-1"> <?= \xtracode\image\widgets\ImageList::widget([ 'model' => $model, 'model_id' => $model->id, ]) ?> </div>
use method $model->uploadSingleImage() in controller:, (*10)
public function actionCreate() { $model = new Article; if ($model->load($_POST) && $model->save()) { $model->uploadSingleImage(); \Yii::$app->session->setFlash('success', \Yii::t('article', 'Article successfully saved')); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', [ 'model' => $model, ]); } }
In view:, (*11)
<div class="col-sm-offset-1"> <?= \xtracode\image\widgets\ImageList::widget([ 'model' => $model, 'model_id' => $model->id, ]) ?> </div>
For more details see the guide., (*12)
Yii2 image module
extension yii2 widget image