Question

when I reference an image in my stylesheet:

background-image:url('../images/logo.svg');

Assetic generates the image paths like this:

../../bundles/myprojectassets/images/logo.svg

Is there any way I can clean this up in my production environment, preferable to something like /images/logo.svg?

Was it helpful?

Solution

I did try and tidy up my image paths in a similar way a while ago when I first started using Symfony, I wanted something similar to what you are describing, however I don't think it is possible.

As far as I'm aware I don't think you can set the output of all the images to a single folder (like /images/) - the only way I could get them to be placed in a set folder was to load each image individually with Assetic -

{% image '@AcmeFooBundle/Resources/public/images/example.jpg'
    output='/images/example.jpg' %}
    <img src="{{ asset_url }}" alt="Example"/>
{% endimage %}

But obviously this isn't very practical.

I would personally let Symfony use it default paths and not worry too much about it, if you really wanted to shorted your image paths maybe you could use a url-rewrite in your public folder?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top