public function actions() { return ['picture-upload' => ['class' => UploadAction::className(), 'deleteRoute' => 'picture-delete', 'on afterSave' => function ($event) { /* @var $file \League\Flysystem\File */ $file = $event->file; $img = ImageManagerStatic::make($file->read())->fit(self::IMAGE_MAX_WIDTH, self::IMAGE_MAX_HEIGHT); $file->put($img->encode()); }], 'picture-delete' => ['class' => DeleteAction::className()]]; }
/** * @return array */ public function actions() { return ['avatar-upload' => ['class' => UploadAction::className(), 'deleteRoute' => 'avatar-delete', 'on afterSave' => function ($event) { /* @var $file \League\Flysystem\File */ $file = $event->file; $img = ImageManagerStatic::make($file->read())->fit(215, 215); $file->put($img->encode()); }], 'avatar-delete' => ['class' => DeleteAction::className()]]; }
public function actions() { return ['avatar-upload' => ['class' => UploadAction::className(), 'deleteRoute' => 'avatar-delete', 'on afterSave' => function ($event) { /* @var $file \League\Flysystem\File */ $height = \Yii::$app->getModule('user')->userPhotoHeight ? \Yii::$app->getModule('user')->userPhotoHeight : 300; $width = \Yii::$app->getModule('user')->userPhotoHeight ? \Yii::$app->getModule('user')->userPhotoHeight : 300; $file = $event->file; $img = ImageManagerStatic::make($file->read())->fit($width, $height); $file->put($img->encode()); }], 'avatar-delete' => ['class' => DeleteAction::className()]]; }