如何在 CDetailView 中添加宽度标签以在 Yii 中显示图像


How to add width tag in CDetailView to display image in Yii

我可以在详细信息视图中显示图像,阅读此无法在 Yii 主题中显示图像。我想将宽度和 alt 标签添加到 img 标签中。可能吗?

我写了如下:

    $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',
    ),
));

您可以添加各种 html 选项,如此处所述。

公共静态字符串图像(字符串$src,字符串$alt='',数组$htmlOptions=数组( ))

所以它会像

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