Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用细枝显示动态图像URL?_Php_Symfony_Twig - Fatal编程技术网

Php 如何使用细枝显示动态图像URL?

Php 如何使用细枝显示动态图像URL?,php,symfony,twig,Php,Symfony,Twig,我恳请您帮助我在细枝模板中显示动态图像URL,如下所示: // non-working pseudocode, myImageFilename contains image filename {% image '@AppBundle/Resources/public/images/' + myImageFilename %} <img src="{{ asset_url }}" /> {% endimage %} 但它也不起作用 {% image '@AppBundle/R

我恳请您帮助我在细枝模板中显示动态图像URL,如下所示:

// non-working pseudocode, myImageFilename contains image filename
{% image '@AppBundle/Resources/public/images/' + myImageFilename %}
    <img src="{{ asset_url }}" />
{% endimage %}
但它也不起作用

{% image '@AppBundle/Resources/public/images/example.jpg' %}
    <img src="{{ asset_url }}" alt="Example"/>
{% endimage %}
{%image'@AppBundle/Resources/public/images/example.jpg%}
{%endimage%}

是否有可能将动态图像URL与此细枝图像逻辑一起使用?

您无法从浏览器客户端(.htaccess deny from all)访问捆绑目录,您必须从./web/目录加载图像,现在,我认为不可能这样做。这背后的原因是Assetic预先运行以转储资产

可以通过这种方式:

<img src="{{ asset('bundles/appbundle/Resources/public/images/'~myImageFilename }}" alt="Example"/>

<img src="{{ asset('bundles/appbundle/Resources/public/images/'~myImageFilename }}" alt="Example"/>