Exemplo n.º 1
0
        </div>
    </div>

    <div class="row">
        <div class="col-md-<?php 
echo $col3;
?>
">

            <div class="image-uploader">
                <?php 
ActiveForm::begin(['method' => 'post', 'action' => Url::to(['/auth/default/upload-avatar']), 'options' => ['enctype' => 'multipart/form-data', 'autocomplete' => 'off']]);
?>

                <?php 
$avatar = ($userAvatar = Yii::$app->user->identity->getAvatar('large')) ? $userAvatar : AvatarAsset::getDefaultAvatar('large');
?>
                <div class="image-preview" data-default-avatar="<?php 
echo $avatar;
?>
">
                    <img src="<?php 
echo $avatar;
?>
"/>
                </div>
                <div class="image-actions">
                    <span class="btn btn-primary btn-file"
                          title="<?php 
echo Yii::t('yee/auth', 'Change profile picture');
?>
Exemplo n.º 2
0
 public function actionRemoveAvatar()
 {
     if (Yii::$app->user->isGuest) {
         throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
     }
     Yii::$app->response->format = Response::FORMAT_JSON;
     try {
         Yii::$app->user->identity->removeAvatar();
         AvatarAsset::register($this->view);
         return AvatarAsset::getDefaultAvatar('large');
     } catch (Exception $exc) {
         Yii::$app->response->statusCode = 400;
         return 'Error occured!';
     }
     return;
 }