Image Size in CDetailView

How can I size the image in CDetailView. I am using the following code in CDetailView widget. Unfortunately the attribute doesn’t have size property.


.....array('type'=>'image','value'=>$model->fileUrl, 'label'=>'Uploaded Image') ...

use cssClass=>‘imagePreview’;

And then add a class to the css:

.imagePreview

{width: 200px;}

I tried:


array('type'=>'image','value'=>$model->fileUrl, 'label'=>'Uploaded Image', 'cssClass'=>'imagePreview'),

in the view file and




.imagePreview

{

	width: 200px;

}

in main.css. But it didn’t help. The size is same and the generated code is:


<img src="/myWebFolder/icfelectcomp/images/dbImages/806ad3b9a13c5bd8430b9877cd8d39e7.jpg" alt="">

the width attribute is missing!!

hello, try the CHtml::image($model->file,‘alt’,array(‘width’=>100,‘height’=>100));

cheers!!!

did you have a answer that works with zii.widgets.CDetailView??

array(

        'label'=&gt;'Service Pic',


        'type'=&gt;'raw',


        'value'=&gt;html_entity_decode(CHtml::image(&#036;model-&gt;fileUrl,'alt',array('width'=&gt;341,'height'=&gt;232))),


       


    ),

cheers!!!!!!!!!!!!!!!!!!!!!!!!!! :D

不错,伙计?

我按这个把图片的尺寸搞出来了。

Goodluck!

+1 it’s best solution

This code show two images correcty!

<?php

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

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


'attributes'=&gt;array(


	//'id',


	'categoria',


	array(


		'name' =&gt; 'activo',


		'value' =&gt; (&#036;model-&gt;activo)?'Sí':'No',


		'htmlOptions'=&gt;array('width'=&gt;'150px'),


	),


	 array(        


		'name'=&gt;'image',


		'type'=&gt;'raw',


		'value'=&gt;  CHtml::image(Yii::app()-&gt;request-&gt;baseUrl.'/'.&#036;model-&gt;image),


            ),


	array(        


		'name'=&gt;'imagehover',


		'type'=&gt;'raw',


		'value'=&gt;  CHtml::image(Yii::app()-&gt;request-&gt;baseUrl.'/'.&#036;model-&gt;imagehover),


            ),		


),

));

?>

Nice topic~It will help me.

This works, thanks!

thanxs this helps me a lot… :)