2013-10-30 18 views
2

我可以在詳細信息視圖中顯示圖像,閱讀cannot display image in Yii主題。我想將width和alt標籤添加到img標籤中。可能嗎?如何在CDetailView中添加寬度標籤以在Yii中顯示圖像

我寫如下:

$this->widget('zii.widgets.CDetailView', array(
    'data'=>$model, 
    'htmlOptions'=>array('class'=>'table table-striped responsive-table'), 
    'attributes'=>array(
     'id', 
     'code', 
     'name', 
     'description', 
     array(
      'type'=>'raw', 
      'width'=>'200', 
      'alt'=>'hi images', 
      'value'=> CHtml::image(Yii::app()->request->baseUrl.'/images/products/'.$model->image), 
     ), 
     'price', 
    ), 
)); 

回答

2

您可以添加HTML選項種種,因爲它是described here

公共靜態字符串圖像(字符串$ SRC,串$ ALT = '',陣列$ htmlOptions =陣列())

所以它會像

CHtml::image(
    Yii::app()->request->baseUrl . '/images/products/' . $model->image , 
    'some thing here' , array(
    'style' => 'width = 200px; height: 100px', 
)); 
+0

做你試試? – tinybyte

+0

謝謝。有用。 – StreetCoder

相關問題