symfony3中的asset()函数不转换url

时间:2017-03-27 14:22:18

标签: php symfony web controller twig

我想从数据库动态加载图片。

这是包含图像信息的表格:

table

控制器代码

public function listeproductAction()
{
    $em = $this->getDoctrine()->getManager();
    $img = $em->getRepository('AppBundle:image')->findAll();
    return $this->render('lucky/images.html.twig', array(
        'img' => $img ,

    ));

}

twig code

{% for im in img %}
 <img src="{{ asset('/uploads/brochures/' ~  im.getBrochure()) }} ">
{% endfor %}

结果

<div class="main-content">
        <img src="/uploads/brochures/0fa58c757752ced32d04b57bb7fa0d65.png ">
    </div>

问题是asset功能无法找到图像。

0 个答案:

没有答案