【问题标题】:set width image gridview yii2设置宽度图像gridview yii2
【发布时间】:2015-08-25 23:43:06
【问题描述】:

我正在尝试在网格视图中设置图像的宽度。

 [   'attribute' => 'iduser.photo',
            'headerOptions' => ['width' => '20px'],
            'format' => 'image',
            'value'=>  function($data) { return Html::img("avatar.jpg",['width'=>'100']); },
        ],

这是模型

public function getImageurl()
{
    return Yii::$app->request->BaseUrl.'/avatar.jpg';
}

但是src结果

http://localhost/belajar4/web/%3Cimg%20src=%22avatar.jpg%22%20width=%22100 %22%20alt=%22%22%3E

【问题讨论】:

    标签: gridview yii yii2 yii2-advanced-app


    【解决方案1】:

    试试raw这样的格式

        [   'attribute' => 'iduser.photo',
            'headerOptions' => ['width' => '20px'],
            'format' => 'raw',
            'value'=>  function($data) { return Html::img("avatar.jpg",['width'=>'100']); },
        ],
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-01
      • 2014-06-21
      • 1970-01-01
      • 2014-04-11
      • 1970-01-01
      • 2014-01-19
      • 2016-02-07
      相关资源
      最近更新 更多