简体   繁体   English

Sonata媒体捆绑中的图像路径

[英]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. 有一种解决方法(通过将CDN路径修改为../../../../uploads),但是我试图找到一种“正常”方式。

尝试

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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