Reputation: 2516
This has had me stomped for the last several hours, and I cannot find how to properly make it work. All the solutions are for local images, but mine crashes on the :
in the http://
.
This is what I have:
$this->widget('bootstrap.widgets.TbGridView', array(
'dataProvider' => $dataProvider,
'columns' => array(
'name',
array(
'name' => 'url',
'type' => 'raw',
'value'=> 'CHtml::image(http://my.domain.com/images/' . $data->url . ')',
),
),
));
I have tried adding parameters like a class, escaping the domain, adding double quotes for the domain, but nothing has worked. Can anyone help?
Upvotes: 0
Views: 637
Reputation: 2516
array(
'name' => 'url',
'type' => 'raw',
'value' => function($data) { return CHtml::image("http://my.domain.com/images/data->url"); },
),
I fixed it by using the above code. Both answers did not work as expected, sadly.
Upvotes: 0
Reputation: 3334
try this
'value'=>function($data) { return addslashes(CHtml::image(Yii::app()->baseUrl.'/images/' . $data->url)); },
Works for me even without escaping the //
using addslashes though.
For an external domain -
'value'=>function($data) { return addslashes(CHtml::image('http://www.google.com'.'/images/' . $data->url)); },
Upvotes: 1
Reputation: 8838
In value, you have to pass url as string in CHtml::image function.
Try below code:
'value'=> 'CHtml::image("http://my.domain.com/images/' . $data->url . '")',
Upvotes: 1