Image is not shown in DetailView::widget

Hi there,

why my image is not shown?




<?= DetailView::widget([

        'model' => $model,

        'attributes' => [

            'id',

            'name',

            'phone',

            'email:email',

            //'img_name:image',

            [

                'attribute' => 'img_name',

                'format' => 'html',

                'label' => 'Studnt image',

                'value' => function ($model) {

                    return Html::img( $model['img_name'],

                        ['width' => '60px']);

                },

            ],

        ],

    ]) ?>



Because in $model->img_name not exactly the path.

make sure your image actually points to a file on the file system. does your img_name column include absolute url with dir or if it is just a filename then you can do something like following.


Html::img("/path/to/upload_dir/" . $model['img_name'], ['width' => '60px']);