简体   繁体   中英

Slightly different syntax for Twig media reference yields different results — why?

I am working on a project that uses Twig and the Sonata Media Bundle.

In one part of my template, I have the following line:

<img src="{% path media, 'reference' %}" >

... and in that same Twig template, I have (inside of a logic block) this line of assignment:

image: {src: path(media, 'reference'), alt:''}

... and while the fist line works, the second yields an error stating:

None of the chained routers were able to generate route: Route 'Story2_Ernährung_damals (1).jpg' not found

What am I doing wrong here?

It looks like I may have to write a Twig extension just to access the image url. Eeep!

Sonata Media Bundle : acces media url

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM