0

My png image is located in src/AppBundle/Resources/public/img

I am trying to set png image through css content property:

content: url(../../public/assets/img/optional-checked.png);

But I am getting

GET http://127.0.0.1:8080/public/assets/img/optional-checked.png 404 (Not Found)

How can I set png image through CSS content property in Symfony project?

2
  • 1
    Use asset keyword. Commented May 10, 2018 at 11:54
  • 1
    if your image located in public/img why you search it in public/assets/img? Commented May 10, 2018 at 12:52

1 Answer 1

1

First suggestion, That's because you need to respect the hierarchy from where you call your CSS not your script.

Another suggestion would be not to use public folder to upload your assets, instead of this, use web folder (in the root), because if you do like I'm saying then the twig views can use properly asset keyword right.

And the last tip, is that you are trying to read your image from public/assets/img/optional-checked.png when you said that your image is really located in public/img.

Hope this helps.

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

Comments

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.