1

I want to realize the following thing: in my parameters.yml I have uploads_url: http://test.site.com. It's a URL to Docker container with my images. Next, I have an entity with names of this pictures.

I want to generate URL in twig like this:

background-image: url({{ 'URL from parameters' + 'name of picture from `entity`' }})

At present time I have the second part of the previous expression (name of the picture). How can I generate the 1st part?

DarkBee
  • 16,592
  • 6
  • 46
  • 58

1 Answers1

2

app/config/config.yml

# Twig Configuration
twig:
    globals:
        url: "%url%"

app/config/parameters.yml

parameters:
    url: 'your_url'

official doc How to Inject Variables into all Templates (i.e. global Variables)

twig concatenate How to concatenate strings in twig

habibun
  • 1,552
  • 2
  • 14
  • 29