dev-master
9999999-devuploader behavior based on mohorev/yii2-upload-behavior
MIT
The Requires
- php >=5.4.0
- yiisoft/yii2 *
- yiisoft/yii2-imagine *
The Development Requires
by muhammad wardany
extension yii2
uploader behavior based on mohorev/yii2-upload-behavior
uploader behavior based on mohorev/yii2-upload-behavior, (*1)
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist wardany/uploader "*"
or add, (*4)
"wardany/uploader": "*"
to the require section of your composer.json
file., (*5)
Once the extension is installed, simply use it in your code by :, (*6)
php
function behaviors()
{
$baseurl = isset(Yii::$app->components['frontend']) ? Yii::$app->urlManagerFrontEnd->baseUrl : Yii::$app->urlManager->baseUrl ;
return [
[
'class' => UploadImageBehavior::className(),
'attribute' => 'image',
'scenarios' => ['insert', 'update'],
'path' => '@frontend/web/media/images/{id}',
'url' => "$baseurl/media/images/{id}",
'unlinkOnDelete'=>true,
'thumbPath' => '@frontend/web/media/images/{id}/thumbnail',
'thumbUrl' => "$baseurl/media/images/{id}/thumbnail",
'thumbs' => [
'header' => ['width' => 1536, 'height' => 600, 'mode'=>ImageInterface::THUMBNAIL_OUTBOUND],
'thumb' => ['width' => 300, 'height' => 300, 'mode'=>ImageInterface::THUMBNAIL_OUTBOUND],
'preview' => ['width' => 100, 'height' => 100, 'mode'=>ImageInterface::THUMBNAIL_OUTBOUND],
],
],
];
}
, (*7)
uploader behavior based on mohorev/yii2-upload-behavior
MIT
extension yii2