2015-08-25 180 views
-1

我想在網格視圖中設置寬度的圖像。設置寬度圖像gridview yii2

[ '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

回答

0

嘗試格式raw這樣

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