'jpeg', 'jpeg' => 'jpeg', 'png' => 'png', 'gif' => 'gif', 'bmp' => 'bmp', ]; public $uploadUrl = '/admin/artboxfile/action/upload'; public function load($file = null, $driver = null) { if(empty($file) || !realpath($file)) { throw new ErrorException('File name can not be empty and exists'); } return Image::factory($file, $driver ? $driver : $this->driver); } public function fileinputWidget($model, $modelField, $formField = 'fileUpload', $multiple = false, $imageOnly = true) { $options = [ 'multiple' => $multiple, ]; if ($imageOnly) { $options['accept'] = 'image/*'; } return FileInput::widget([ 'name' => $formField, 'options' => $options, 'pluginOptions' => [ 'allowedFileExtensions' => array_keys($this->extensions), // @todo set for multiple 'initialPreview' => $model->{$modelField} ? Html::img($modelField) : '', 'overwriteInitial' => !$multiple, 'showRemove' => true, 'showUpload' => false, 'uploadUrl' => $this->uploadUrl, 'uploadExtraData' => [ 'fileField' => $modelField, 'multiple' => intval($multiple), ], ], ]); } }