Akhmed
Akhmed

Reputation: 1179

Symfony 2 image with relative path display

I don't understand, why relative path for my image url don't work.

My image located at /web/bundles/mybundle/upload/image.jpg

In my template:

<img src = "bundles/mybundle/upload/image.jpg"/>

Application entry point - app.php is located in /web folder, on the same level as bundles folder and I suppose to see my image, when I render template.

But it seems, that image path is incorrect, because I do not see my image.

Only absolute path, with host, renders it correctly.

Can I use relative path or should proceed with absolute?

Upvotes: 0

Views: 1750

Answers (1)

Florian Klein
Florian Klein

Reputation: 8915

you should use the embeded asset package system, that resolves correctly the assets relative paths:

<img src="{{ asset('bundles/mybundle/upload/image.jpg') }}" />

Note that adding a leading slah ("/") has an impact.

Upvotes: 1

Related Questions