alvinojutsu / yii2-image-cropper
yii2 图像裁剪器
dev-master
2017-05-11 13:58 UTC
Requires
- bower-asset/cropper: *
- bower-asset/fontawesome: *
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2024-09-29 03:04:43 UTC
README
yii2 图像裁剪器
此仓库是基于https://github.com/navatech/yii2-cropper修改的
增强
- 裁剪一个图像到多个尺寸
- 缩略图默认尺寸
安装
安装此扩展的首选方式是通过 Composer。
运行
php composer.phar require --prefer-dist alvinojutsu/yii2-image-cropper "*"
或添加
"alvinojutsu/yii2-image-cropper": "*"
到您的composer.json
文件的require部分。
使用方法
扩展安装后,只需在您的代码中使用它即可
无 $model
<?= \alvinux\imagecropper\Cropper::widget([ 'name' => 'Post[picture]', // 'value' => 'https://fengyuanchen.github.io/cropper/images/picture.jpg', // Default blank image if not sett 'options' => [ ['width' => 200,'height' => 200], ['width' => 500,'height' => 200], ['width' => 500,'height' => 100], ], 'showThumbnailCropper' => true, // optional, if ( showThumbnailCropper == false && autoCrop == true ) then 'hidden' else 'show', 'autoCrop' => true, // optional, default (true), if autoCrop = 'true' there is no "Crop Image" button, if set false then you have to click 'Crop Image' button to get value 'thumbnail' => ['width' => 250, 'height' => 250], // optional, default 150 x 150 'pluginOptions' => [ // https://github.com/fengyuanchen/cropper // Options default // 'autoCropArea' => true, // 'strict' => false, // 'guides' => true, // 'highlight' => true, ] ]); ?>
有 $model
<?= \alvinux\imagecropper\Cropper::widget([ 'model' => $model, 'attribute' => 'picture', 'options' => [ ['width' => 200,'height' => 200], ['width' => 500,'height' => 200], ['width' => 500,'height' => 100], ], 'showThumbnailCropper' => true, // optional, if ( showThumbnailCropper == false && autoCrop == true ) then 'hidden' else 'show', 'autoCrop' => true, // optional, default (true), if autoCrop = 'true' there is no "Crop Image" button, if set false then you have to click 'Crop Image' button to get value 'thumbnail' => ['width' => 250, 'height' => 250], // optional, default 150 x 150 'pluginOptions' => [ //https://github.com/fengyuanchen/cropper ] ]); ?>