Display image in grid view YII2

By August 26, 2016PHP, Programming, YII

In YII2 there are many function including built-in helper for building urls. So we can easily build the url to image by path too .

To display the image in grid view :

   'attribute' ='image',
   'format' ='html',    
   'value' =function($data) {
      return Html::img(\Yii::$app->request->BaseUrl.'/uploads/'.$data->image,['width'=100]);

To display the image in DetailView :

 'format' =['image',['width'='100','height'='100']],
Pankaj Singh Sugara

Author Pankaj Singh Sugara

More posts by Pankaj Singh Sugara