simialbi/yii2-widget-crop

Image Cropper JavaScript 库的 Yii2 包装器

安装: 435

依赖项: 0

建议者: 1

安全性: 0

星标: 0

关注者: 2

分支: 3

公开问题: 0

类型:yii2-extension

1.1.1 2022-09-12 07:06 UTC

This package is auto-updated.

Last update: 2024-09-12 11:52:13 UTC


README

基于 Image Cropper JavaScript 库和 demisang/yii2-cropper 的包装器。

资源

安装

安装此扩展的首选方法是通过 composer

运行以下命令之一

$ php composer.phar require --prefer-dist "simialbi/yii2-crop"

{
	"require": {
  		"simialbi/yii2-crop": "~1.0"
	}
}

将以下内容添加到您的 composer.json 文件的 require 部分

示例用法

<?php
/* @var $this yii\web\View */
/* @var $image stdClass */

use simialbi\yii2\crop\Cropper;

$this->title = 'my example';
$this->params['breadcrumbs'][] = $this->title;

?>
<div class="my-example">
<?php
echo Cropper::widget([
	'type' => Cropper::TYPE_MODAL,
	'cropUrl' => ['my-module/image/crop', 'id' => $image->id],
	'image' => $image->src,
	'aspectRatio' => 16 / 9,
	'clientOptions' => [
		//see https://github.com/fengyuanchen/cropper/blob/master/README.md#options
		'minCropBoxWidth' => 1600,
		'minCropBoxHeight' => 900
	],
	'options' => [],
	'imageOptions' => [],
	'modalOptions' => [],
	'buttonOptions' => [
		'class' => ['btn', 'btn-default']
	],
	'buttonContent' => 'Crop {icon}',
	'buttonIcon' => '<span class="glyphicon glyphicon-scissors"></span>',
	'ajaxOptions' => [] //$.ajax properties
]);
?>
</div>

许可证

yii2-widget-crop 在 MIT 许可证下发布。有关详细信息,请参阅捆绑的 LICENSE