FahadAkram
FahadAkram

Reputation: 465

Yii1 Detail View , how to add class to image

I am using yii1 and facing problem in adding class to image shown in detail view , tell me how to add css class or static property to image to make width and height 40px; my detail view code is below

   <?php
$this->widget('zii.widgets.CDetailView', array(
    'data' => $model,
    'attributes' => array(
        'id',
        'title',
        array(
            'label' => 'image',
            'type' => 'image',
            'value' => Yii::app()->baseUrl . '/images/foodcategory/' 

.$model->image ,
            ),
        'status',
        'created_at',
        'created_by',
        'modified_at',
        'modified_by',
    ),
));
?>

Upvotes: 1

Views: 1328

Answers (2)

ismail akheel
ismail akheel

Reputation: 1

[
    'attribute'=>'image_url',
    'type' => 'image',
    'value'=> \Yii::$app->request->BaseUrl.'/'.$model->image_url,
    'format'=> ['image',['width'=>'100','height'=>'100']],
],

Upvotes: 0

topher
topher

Reputation: 14860

Change the type to raw. You can then add it using CHtml::image():

array(
    'label' => 'image',
    'type' => 'raw',
    'value' => CHtml::image(
        Yii::app()->baseUrl . '/images/foodcategory/'.$model->image,
        'Alt text',
        array('class' => 'myclass') //and other html tag attributes
    ),
),

Upvotes: 4

Related Questions