Reputation: 1520
I have many images in backends web folder, I want to use those images in frontend how to get those files?
I need to display 1 (first) image which path is saved in database like Img1.jpg;img2.jpg;
<?php
foreach (explode(';',rtrim($row['images'],';'),1) as $key_img => $value_img)
{
?>
<?php echo Html::img('@backend/web'.'/'.$value_img);?>
<?php
}
?>
Upvotes: 0
Views: 1115
Reputation: 5456
Simply try:
<?= \yii\helpers\Html::img( Yii::getAlias('@backend'). '/web/images/your-image.jpg') ?>
Upvotes: 0
Reputation: 638
<?= \yii\helpers\Html::img('@backend/web/images/your-image.jpg') ?>
The src parameter, containing the backend alias, will be processed by Url::to()
Check the docs for details on Html::img()
.
Upvotes: 1