Reputation: 3547
I want to print an image in a backend view. the image exists in frontend, so I used the alias to print it like:
<img src="<?= Yii::getAlias('@frontendWeb') . "/uploads/clients/{$model->img}"; ?>"/>
where the @frontendWeb
alias is defined in common\config\bootstrap
as:
Yii::setAlias('@frontendWeb', dirname(dirname(__DIR__)) . '/frontend/web');
the image URL is true, and I can see it if I open its URL directly from the browser, but unfortunately it didn't shown in the view file.
Upvotes: 1
Views: 1068
Reputation:
try this
<img src="<?= Yii::getAlias('@frontendWeb') . "/uploads/clients/" . $model->img . ".jpg" ?>" class="photos"/>
Upvotes: 1
Reputation: 892
Why not use direct links, as the images in front-end are accessible publicly anyways
<img src="<?= Url::base(true) ?>"/uploads/clients/"<?= {$model->img} ?>"/>
Upvotes: 1