Sonata Media Bundle : acces media url

前端 未结 5 2037
小蘑菇
小蘑菇 2021-01-02 01:09

I am using sonata media bundle.

and I was wondering how can I access the media url in twig.
I just want the url, I do not need to show the media.

Any sug

5条回答
  •  没有蜡笔的小新
    2021-01-02 01:52

    You can use: {% path media, 'reference' %}

    @Blauesocke - tried your solution and had exactly the same result for file provider with using both

    {% set img_url = media_public_url(media, 'reference') %}
    {{ dump(img_url) }}
    

    and

    {%  path sonata_admin.value, 'reference' %}
    

提交回复
热议问题