I am trying to render an Image in view file. My code is like below:
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'name',
//'photo',
[
'attribute'=>'photo',
'value'=>('<img src =' .'uploads/' . $model->photo . ' height="100" width="100"' . '>')
],
[
'attribute' => 'birth_date',
'format' => ['date', 'dd-MM-Y'],
],
'mobile',
],
]) ?>
Though the code below works:
<?php echo ('<img src =' .'uploads/' . $model->photo .'>'); ?>
Thanks.
Try this:
[
'attribute'=>'photo',
'value'=>$model->photo,
'format' => ['image',['width'=>'100','height'=>'100']],
],
DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'photo:image',
],
])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With