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') ...
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'=>'Service Pic',
'type'=>'raw',
'value'=>html_entity_decode(CHtml::image($model->fileUrl,'alt',array('width'=>341,'height'=>232))),
),
cheers!!!!!!!!!!!!!!!!!!!!!!!!!!
不错,伙计?
我按这个把图片的尺寸搞出来了。
Goodluck!
+1 it’s best solution
This code show two images correcty!
<?php
$this->widget(‘zii.widgets.CDetailView’, array(
'data'=>$model,
'attributes'=>array(
//'id',
'categoria',
array(
'name' => 'activo',
'value' => ($model->activo)?'Sí':'No',
'htmlOptions'=>array('width'=>'150px'),
),
array(
'name'=>'image',
'type'=>'raw',
'value'=> CHtml::image(Yii::app()->request->baseUrl.'/'.$model->image),
),
array(
'name'=>'imagehover',
'type'=>'raw',
'value'=> CHtml::image(Yii::app()->request->baseUrl.'/'.$model->imagehover),
),
),
));
?>
Nice topic~It will help me.
This works, thanks!
thanxs this helps me a lot…