0

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Could you explain more why adding a leading slash has an impact?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.