Hi all, i want to display an image in my gridview
I try in this simple way and it works:
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
[
'format' => 'image',
'value'=>function($data) { return $data->file; },
],
],
]); ?>
Now i want to specify html options for my image, in particular the class and the width
and i do the follow code reading yii\grid\Column documentation,without success:
[
'format' => 'image',
'value'=>function($data) { return $data->file; },
'options'=>['class'=>'img-responsive','width'=>'100px']
],
with this code the image doesn’t affect with my htmloptions.
So i try in another way:
[
'format' => 'raw',
'value'=>function($data) { return Html::img($data->file,['style'=>['width'=>'100px'],'class'=>'img-responsive']); },
],
and now it works.
My question is, what’s wrong in my first attempt? What is the difference between these two methods?
Thank’s for any suggestion.