hajdar
(Hajdardushku)
1
Hello!
I am trying to display an image in a view using Yii2 with method Html::img():
the code is simple:
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\Url;
<?= Html::img('images/test.jpeg');?>
I just added the source.
Do I have to add additional options?
thanks
hrnair
(Harikrishnan Hr)
2
it’s your choice. <?= Html::img(‘images/test.jpeg’, [‘alt’=>‘some’, ‘class’=>‘thing’]);?>
1 Like
yaasky
(Xigbanam)
3
With the images, you should reference the folder you are trying to load the image from.
For instance, if the images folder is under frontend/web, the tag should read thus
<?php echo Html::img('@web/images/test.jpeg') ?>
1 Like
so this is for the frontend
<?php echo Html::img('@web/images/test.jpeg') ?>
how to display backend/web/ images on frontend views?
Bizley
(Bizley)
5