Image as link to original image in CDetail View

Hello,

I am using following code to display product details on my view page:

<?php $this->widget(‘zii.widgets.CDetailView’, array(

'data'=&gt;&#036;model,


'attributes'=&gt;array(


	'title',


	array(                  


                'label'=&gt;'Time to bid', 


                'value'=&gt;&#036;timetobid,


            ), 


	array(                  


                'label'=&gt;'Budget', 


                'value'=&gt;&#036;budget,


            ), 


	array(                  


                'label'=&gt;'Photo',


                'type'=&gt;'image',   


                'value'=&gt;Yii::app()-&gt;baseUrl . '/images/projectthumbs/' . &#036;model-&gt;photo, 


            ),  

?>

It works well, however, the image that gets displayed is a small thumb of original thumbs, i want to make it a link to original image because i am saving them both.

Please suggest me a way to achive this!

Thanks,

Kul.

This would probably work:


'value'=>CHtml::link(Yii::app()->baseUrl . '/images/projectthumbs/' . $model->photo, Yii::app()->baseUrl . '/images/' . $model->photo), 

Haven’t tested, though. ;)

Hi,

Thanks for replying, but, i’ve already tested that, it works only for

‘type’=>‘raw’,

Not for

‘type’=>‘image’,

And hence doesn’t display the image at all.

What I did in a project of mine was to just hardcode the img tag, like this::


CHtml::link('<img src="'.Yii::app()->baseUrl . '/images/projectthumbs/' . $model->photo .'"/>', array(Yii::app()->baseUrl . '/images/' . $model->photo, "id" => $user->id))

Type raw, of course.

Works like a charm.

But, it makes the url as:

http://www.servername.com/index.php?r=zola/images/projectimages/809b.gif

which returns "Unable to resolve the request "zola/images/projectimages/809b.gif"."

Anyways, i used:

‘value’=>CHtml::link(’<img src="’.Yii::app()->baseUrl . ‘/images/projectthumbs/’ . $model->photo .’"/>’ , ‘#’, array (‘onclick’=>“window.open(’”.Yii::app()->baseUrl . “/images/projectimages/” . $model->photo ."’, ‘orgimage’, ‘height= 400, width=500’)" ))),

can u suggest me im displaying from database

is it correct if i put

‘value’=>’<img class=“imgbrder” src="’.$this->createUrl(‘loadImage&id=’.$model->primaryKey).’" alt="’.$model->fileName.’" />"’,

but i got diff i posted image can u help out

The your loadimage action first.

For example, can you see the image when you navigate to the action directly?