Z
Z
ZaurK2016-09-27 11:19:35
Yii
ZaurK, 2016-09-27 11:19:35

How to display a photo from a link saved in the database?

I'm trying to get an image in a view in the following way:

echo Html::img($model->image, ['class'=>'img-responsive']);

as a result, I get the link backend.alf.loc/goods/images/123.jpg . The link is stored in the database as images/123.jpg.
Now, if there was no 'goods' (this is the controller), then the link would be correct. I tried to write an alias, but still 'goods' interferes, please tell me how to write it down correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2016-09-27
@ZaurK

Try making the path absolute:

echo Html::img('/' . $model->image, ['class'=>'img-responsive']);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question