you should go like this
echo CHtml::image(Yii::app()->request->baseUrl .'/images/vegetables/'.$data->img_name , '', array(
'style' => 'width:200px; height: 100px'));
first parameter is url, sceond is alt and third is an array of html options
Question
In my web application I want to change the height and width of uploaded image in index action _view template. I tried this code but it is not working. How should I change my code. Any body help me how should I change my code.
<b><?php echo CHtml::encode($data->getAttributeLabel('img_name')); ?>:</b>
<?php echo CHtml::image(Yii::app()->request->baseUrl .'/images/vegetables/'.$data->img_name, array(
'style' => 'width = 200px; height: 100px')); ?>
This is the error I am getting
htmlspecialchars() expects parameter 1 to be string, array given
How should I proceed.
Solution
you should go like this
echo CHtml::image(Yii::app()->request->baseUrl .'/images/vegetables/'.$data->img_name , '', array(
'style' => 'width:200px; height: 100px'));
first parameter is url, sceond is alt and third is an array of html options
OTHER TIPS
getAttributeLabel('image')); ?>:
baseUrl . "/images/" . $data->image, "this is alt tag of image", array('height'=>'150', 'width'=>'150')); ?>
"this is alt tag if image"==> this is reuired to seperate the data before defining height and width