PHPackages                             flash20/yii2-avatar - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. flash20/yii2-avatar

ActiveYii2-extension[File &amp; Storage](/categories/file-storage)

flash20/yii2-avatar
===================

基于cropper的一款头像上传yii2组件

1.0.0(8y ago)1251BSD-4-ClauseJavaScript

Since May 4Pushed 7y ago1 watchersCompare

[ Source](https://github.com/flash81/yii2-avatar)[ Packagist](https://packagist.org/packages/flash20/yii2-avatar)[ RSS](/packages/flash20-yii2-avatar/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

头像上传
====

[](#头像上传)

基于cropper的一款头像上传yii2组件

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer require --prefer-dist flash20/yii2-avatar

```

or add

```
"flash20/yii2-avatar": "1.0.0"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

Once the extension is installed, simply use it in your code by :

```
//在当前控制器的actions中添加如下配置
public function actions()
{
    return [
        'crop'=>[
            'class' => 'flash20\avatar\CropAction',
            'config'=>[
                'bigImageWidth' => '200',     //大图默认宽度
                'bigImageHeight' => '200',    //大图默认高度
                'middleImageWidth'=> '100',   //中图默认宽度
                'middleImageHeight'=> '100',  //中图图默认高度
                'smallImageWidth' => '50',    //小图默认宽度
                'smallImageHeight' => '50',   //小图默认高度

                //头像上传目录（注：目录前不能加"/"）
                'uploadPath' => 'uploads/avatar',
            ]
        ]
    ];

}

//调用方式,imageUrl为默认图地址
