I have a picture in folder common that i want to show in view, but it doesn't shown.
My code is :
<img src="<?= Yii::$app->request->baseUrl . '/common/web/img/ava.jpg' ?>" class=" img-responsive" >
It's generated to be <img src="/simdsm/common/web/ava.jpg" class=" img-responsive">
but the image does not appear.
How to fix it?
We can do it easily by simple step of below In common/config/params-local.php
in above example i have my image under backend/web/images/product_images
In frontend, i am getting like,
it's simply working for me...
In case of using advanced application template, images should be placed in these web accessible folders -
frontend/web
orbackend/web
.Also usually I create alias from
frontend/web/images
tobackend/web/images
to display images in backend from frontend.What you mentioned is not web accessible directory.
Alternative way to publish images from such directory will be creating asset bundle for that folder, that way images will be copied in
frontend/web/assets
for example. You can read more about asset bundles in official docs.