newerton / yii2-jcrop
Jcrop 是将图像裁剪功能快速方便地添加到您的 Web 应用程序中的方法。
dev-master
2014-11-21 17:09 UTC
This package is auto-updated.
Last update: 2024-09-10 05:41:04 UTC
README
Jcrop 是将图像裁剪功能快速方便地添加到您的 Web 应用程序中的方法。它结合了典型 jQuery 插件的易用性与一个功能强大的跨平台 DHTML 裁剪引擎,该引擎忠实于熟悉的桌面图形应用程序。
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一:
php composer.phar require --prefer-dist newerton/yii2-jcrop "dev-master"
或
"newerton/yii2-jcrop": "dev-master"
将其添加到您的 composer.json
文件的 require 部分。
使用方法
扩展安装完成后,只需在代码中通过以下方式使用它:
<?php echo \newerton\jcrop\jCrop::widget([ // Image URL 'url' => '/path/to/full/image.jpg', // options for the IMG element 'imageOptions' => [ 'id' => 'imageId', 'width' => 600, 'alt' => 'Crop this image' ], // Jcrop options (see Jcrop documentation [http://deepliquid.com/content/Jcrop_Manual.html]) 'jsOptions' => array( 'minSize' => [50, 50], 'aspectRatio' => 1, 'onRelease' => new yii\web\JsExpression("function() {ejcrop_cancelCrop(this);}"), //customization 'bgColor' => '#FF0000', 'bgOpacity' => 0.4, 'selection' => true, 'theme' => 'light', ), // if this array is empty, buttons will not be added 'buttons' => array( 'start' => array( 'label' => 'Adjust thumbnail cropping', 'htmlOptions' => array( 'class' => 'myClass', 'style' => 'color:red;' ) ), 'crop' => array( 'label' => 'Apply cropping', ), 'cancel' => array( 'label' => 'Cancel cropping' ) ), // URL to send request to (unused if no buttons) 'ajaxUrl' => 'controller/ajaxcrop', // Additional parameters to send to the AJAX call (unused if no buttons) 'ajaxParams' => ['someParam' => 'someValue'], ]); ?>