bluehe/yii2-jcrop

Jcrop 是为您的网络应用快速添加图像裁剪功能的一种简便方式。它已经升级到 Jcrop-WIP-2.x

安装次数: 47

依赖项: 1

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

语言:JavaScript

类型:yii2-extension

dev-master 2017-01-01 05:10 UTC

This package is not auto-updated.

Last update: 2024-09-27 22:10:17 UTC


README

Jcrop 是为您的网络应用快速添加图像裁剪功能的一种简便方式。它结合了典型 jQuery 插件的易用性以及一个强大的跨平台 DHTML 裁剪引擎,该引擎忠实于熟悉的桌面图形应用。

安装

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

运行以下命令之一

php composer.phar require --prefer-dist bluehe/yii2-jcrop "dev-master"

或者在您的 composer.json 文件的 require 部分添加以下内容

"bluehe/yii2-jcrop": "dev-master"

使用

扩展安装完成后,只需在您的代码中通过以下方式使用它

<?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'],
]);
?>