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

Experienced Software Engineer with a demonstrated history of working in the marketing and advertising industry. Skilled in SQL, Web Applications, PHP, WordPress, and Joomla. Strong engineering professional with a B-TECH focused in Information Technology from JCDM College of Engineering Sirsa, Haryana.

More posts by Pankaj Singh Sugara