This is replacement of classic file upload HTML form element. Advantages of this field are:
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist mmedojevicbg/yii2-smart-image-field "dev-master"
or add
"mmedojevicbg/yii2-smart-image-field": "dev-master"
to the require section of your composer.json
file.
1) Attach ImageUploadAction to designated controller
class SiteController extends BaseController
{
function actions()
{
return [
'upload' => [
'class' => 'mmedojevicbg\SmartImageField\ImageUploadAction',
'uploadsPath' => \Yii::getAlias('@webroot') . '/uploads',
'uploadsUrl' => '/uploads'
]
];
}
}
2) Utilize SmartImageField inside ActiveForm
echo SmartImageField::widget(['model' => $model,
'attribute' => 'profile_image',
'uploadsHandler' => '/site/upload']);
No stable releases.
Comments