aleksandrol/yii2-jcrop

Jcrop 是将图像裁剪功能快速轻松地添加到您的 Web 应用程序的一种方式。(由 Newerton Vargas de Araujo 分支开发)

安装次数: 1,211

依赖者: 0

建议者: 0

安全性: 0

星标: 0

关注者: 1

分支: 6

语言:JavaScript

类型:yii2-extension

dev-master 2020-12-09 14:00 UTC

This package is not auto-updated.

Last update: 2024-09-26 07:45:36 UTC


README

Jcrop 是将图像裁剪功能快速轻松地添加到您的 Web 应用程序的一种方式。它结合了典型 jQuery 插件的易用性以及一个强大且跨平台的 DHTML 裁剪引擎,该引擎与熟悉的桌面图形应用程序保持一致。

安装

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

运行以下命令:

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

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

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

使用方法

扩展安装完成后,只需在代码中使用它即可:

<?php
echo \aleksandrol\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'],
]);
?>