Symfony2中的资产多个图像

时间:2014-02-11 14:05:37

标签: symfony

我在config.yml中有以下几行:

assetic:
    # ...
    assets:
        image1:
            input: @bundle/Resource/images/image1.png
            output: images/image1.png

        image2:
            input: @bundle/Resource/images/image2.png
            output: images/image2.png

如何一次或通过面具复制一些文件?

例如:

assetic:
    # ...
    assets:
        images:
            input: @bundle/Resource/images
            output: images

或:

assetic:
    # ...
    assets:
        images:
            input: @bundle/Resource/images/*.png
            output: images/*.png

1 个答案:

答案 0 :(得分:1)

为什么要在config.yml中添加图片?

首选assets:install命令。它将您的Bundle/Resources/public目录复制到您的web目录。因此,将您的图像放在Bundle/Resources/public/images中,运行命令并在您查看中使用您的资源:

{% image '@Bundle/Resources/public/images/image.png'%}
    <img src="{{ asset_url }}" alt="">
{% endimage %}