PaoloVIP
(Paolo Visnoviz)
November 3, 2014, 9:09am
1
Hello,
please one little help. In gridview there is an image field:
'attribute' => 'photo',
'format' => 'image',
'value' => function($data) { return '/' . $data->thumb ; },
'contentOptions' => ['class' => 'thumb-img']
How it can be possible setting a linkable img ?
<a class"some-other-class" href="$data->full_image">
<img src="$data->thumb" />
</a>
samdark
(Alexander Makarov)
November 3, 2014, 9:40am
2
'attribute' => 'photo',
'format' => 'raw',
'value' => function($data) {
return Html::a(Html::img($data->thumb), $data->full_image);
},
'contentOptions' => ['class' => 'thumb-img']
PaoloVIP
(Paolo Visnoviz)
November 3, 2014, 10:10am
3
samdark:
'attribute' => 'photo',
'format' => 'raw',
'value' => function($data) {
return Html::a(Html::img($data->thumb), $data->full_image);
},
'contentOptions' => ['class' => 'thumb-img']
Thank you, works fine. Only one more info, please. It is possible to set a different/additional class only for the link and open this in new page (_blank) ?
return Html::a(Html::img($data->thumb), $data->full_image), myclass, _blank;
samdark
(Alexander Makarov)
November 3, 2014, 12:53pm
4
Sure. Check API of Html::a.
PaoloVIP
(Paolo Visnoviz)
November 6, 2014, 11:50am
5
Thank you Samdark.
[
'attribute' => 'photo',
'format' => 'raw',
'value' => function($data) {
return Html::a(Html::img('/' . $data->thumb), '/' . $data->maximg,
[
'class' => 'thumb-img',
'target' => '_blank',
'data-lightbox' => '$data->maximg'
]);
},
],