Yii Framework Forum: Image Size in CDetailView - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Image Size in CDetailView Adjusting image size Rate Topic: -----

#1 User is offline   thammu 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 55
  • Joined: 04-October 09

Posted 03 February 2011 - 07:00 AM

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') ...

0

#2 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,159
  • Joined: 04-October 09
  • Location:Moscow

Posted 03 February 2011 - 07:06 AM

use cssClass=>'imagePreview';

And then add a class to the css:

.imagePreview
{width: 200px;}
0

#3 User is offline   thammu 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 55
  • Joined: 04-October 09

Posted 03 February 2011 - 10:12 AM

View Postzaccaria, on 03 February 2011 - 07:06 AM, said:

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!!
0

#4 User is offline   binkabir 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 192
  • Joined: 25-July 10
  • Location:Abuja,Nigeria

Posted 04 February 2011 - 11:52 AM

hello, try the CHtml::image($model->file,'alt',array('width'=>100,'height'=>100));
cheers!!!
0

#5 User is offline   quantico 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 49
  • Joined: 05-May 11
  • Location:Guatemala

Posted 11 May 2011 - 08:07 PM

View Postthammu, on 03 February 2011 - 07:00 AM, said:

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') ...



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

#6 User is offline   Nirmal 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 22-August 11

Posted 23 August 2011 - 07:39 AM

View Postquantico, on 11 May 2011 - 08:07 PM, said:

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!!!!!!!!!!!!!!!!!!!!!!!!!! :D
0

#7 User is offline   shchzh85 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 16-September 10

Posted 26 August 2011 - 04:09 AM

不错,伙计?
0

#8 User is offline   shchzh85 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 16-September 10

Posted 26 August 2011 - 04:13 AM

View PostNirmal, on 23 August 2011 - 07:39 AM, said:

array(

'label'=>'Service Pic',
'type'=>'raw',
'value'=>html_entity_decode(CHtml::image($model->fileUrl,'alt',array('width'=>341,'height'=>232))),

),

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

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

#9 User is offline   Tureckiy 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 15-November 11

Posted 05 December 2011 - 06:24 PM

View PostNirmal, on 23 August 2011 - 07:39 AM, said:

array(

'label'=>'Service Pic',
'type'=>'raw',
'value'=>html_entity_decode(CHtml::image($model->fileUrl,'alt',array('width'=>341,'height'=>232))),

),

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

+1 it's best solution
0

#10 User is offline   Touzas 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 16-November 11

Posted 25 September 2012 - 02:38 AM

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),
),
),
));
?>
0

#11 User is offline   jolin_p 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 15-January 13

Posted 23 January 2013 - 10:05 PM

Nice topic~It will help me.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
1 members, 1 guests, 0 anonymous users

  1. vijayakumar