2017-25 © Pedro Peláez
 

yii2-behavior yii2-avatar-behavior

Behavior for the transparent operations of avatar thumbnails

image

brussens/yii2-avatar-behavior

Behavior for the transparent operations of avatar thumbnails

  • Sunday, November 15, 2015
  • by brussens
  • Repository
  • 1 Watchers
  • 0 Stars
  • 49 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 23 % Grown

The README.md

Yii2 avatar behavior

Behavior for the transparent operations of avatar thumbnails, (*1)

Latest Stable Version Total Downloads License, (*2)

Install

Either run, (*3)

php composer.phar require --prefer-dist brussens/yii2-avatar-behavior "*"

or add, (*4)

"brussens/yii2-avatar-behavior": "*"

to the require section of your composer.json file., (*5)

Model configurations

Add a new attribute to the user's model, such as "userpic", (*6)

Add to your user model:, (*7)

namespace common\models;

use yii\db\ActiveRecord;
use brussens\behaviors\AvatarBehavior;

class User extends ActiveRecord
{
    public static function tableName()
    {
        return '{{%user}}';
    }

    public function behaviors()
    {
        return [
            'avatarBehavior' => [
                'class' => AvatarBehavior::className(),
                'attribute' => 'userpic'
            ]
        ];
    }
}

Use

//Returns user avatar as Html::img()
echo Yii::$app->getUser()->getIdentity()->getThumb(30, 30, [
    'class' => 'img-thumbnail'
]);

//Returns user avatar url
echo Html::img(Yii::$app->getUser()->getIdentity()->getThumbUrl(30, 30));

//Some user
$user = User::findOne(1);
echo $user->getThumb(20, 20);

The Versions

15/11 2015

dev-master

9999999-dev https://github.com/brussens/yii2-avatar-behavior

Behavior for the transparent operations of avatar thumbnails

  Sources   Download

MIT

The Requires

 

by Brusenskiy Dmitry

yii2 yii 2 behavior avatar

15/11 2015

0.1.0

0.1.0.0 https://github.com/brussens/yii2-avatar-behavior

Behavior for the transparent operations of avatar thumbnails

  Sources   Download

MIT

The Requires

 

by Brusenskiy Dmitry

yii2 yii 2 behavior avatar