Hi All
I am trying to render an image with CgridView but I am stuck in one problem.
The code that I am writing is
array(
'name'=>'strSitePhotograph',
'type'=>'image',
'value'=> '"/themes/wild/images/" . $data->strSitePhotograph',
),
It shows up the image tag but my actual path to the image is http://localhost/projectname/themes/wild/images/imageName
but I am getting only the path that is mentioned in the value field
What will be the appropriate solution that allows me to get the proper path
I also tried to use Yii::app()->request->baseUrl and Yii::app()->request->hostInfo but all in vain
Any help is highly appreciated
Regards
jkofsky
(Jkofsky)
2
have you tried createUrl()?
I’m new at this but, something like:
'value'=> 'Yii::app()->createUrl("/themes/wild/images/") . $data->strSitePhotograph',
You may need to move the trailing slash after ‘images’ between create URL() and $data->strSitePhotograph.
Hope this at least points you in the right direction.
This is what I do if I dont have the full path within the attribute and I want to set the attributes of the image:
I create a property:
public function getThumb(){
return CHtml::image(Yii::app()->getBaseUrl().'/images/'.$this->strSitePhotograph,'relhere',array('width'=>124));
}
Then on CGridView I point to the thumb property.
Or, you dont care about the size?
‘value’=>‘Yii::app()->getBaseUrl().\’/images/\’.$this->strSitePhotograph;’,
Cheers