PHP code example of xwl / yii2-avatar
1. Go to this page and download the library: Download xwl/yii2-avatar library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
xwl / yii2-avatar example snippets
//在当前控制器的actions中添加如下配置
public function actions()
{
return [
'crop'=>[
'class' => 'xwl\avatar\CropAction',
'config'=>[
'bigImageWidth' => '200', //大图默认宽度
'bigImageHeight' => '200', //大图默认高度
'middleImageWidth'=> '100', //中图默认宽度
'middleImageHeight'=> '100', //中图图默认高度
'smallImageWidth' => '50', //小图默认宽度
'smallImageHeight' => '50', //小图默认高度
//头像上传目录(注:目录前不能加"/")
'uploadPath' => 'uploads/avatar',
]
]
];
}
<?= \xwl\avatar\AutoloadExample::widget();
php composer.phar