I would like to display an image on my page, like this:
<img src="{{ asset('image.png') }}"/>
The image is located in assets/image.png
If I open the page, the result is this:
<img src="/image.png"/>
But the image can not be found on that url.
I suspect, that the image.png
has to be copied somehow to the /public directory
, but Symfony did not copy it there, and I have no idea which command to run, to automatically copy the required assets like that.
Unless you do a special treatment on the image, you don't really need to put it in the assets folder. You can just put it in the public folder, in a subfolder ideally.
Or you can keep it in the assets folder, and use this : https://symfony.com/doc/current/frontend/encore/copy-files.html
To copy it with webpack on build time.