简体   繁体   中英

Image path in Sonata media bundle

I am trying to find the correct way to display an image with sonata media bundle.

cdn:
    server:
        path: %kernel.root_dir%/../web/uploads

The twig file

{% path  user.image, 'big' %} <br>
<img src="{% path  user.image, 'big' %}" alt="image" class="my-4"/>

The result

C:\XXX\www\XXX\app/../web/uploads/image/0001/01/thumb_2_image_big.png  
image

Now if I copy and paste the first link in the browser, it takes me to the image. But if I use it as a path of an image tag, it does not show, as demonstrated.

There is a workaround for that (by modifying cdn path to ../../../../uploads), but I am trying to find a "normal" way.

尝试

<img src="{% path user.image, 'reference' %}" ...

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