Image path in Sonata media bundle

1.3k views Asked by At

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.

1

There are 1 answers

6
haltaction On

Try

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