VichUploaderBundle twig无法获取文件名属性值:"image"

Kio*_*aza 1 symfony symfony-2.1

我在使用VichUploaderBundle时遇到了问题.正确上传文件,但是当我写的时候

<td><img src="<img src="{{ vich_uploader_asset(entity, 'image') }}" alt="{{ entity.nombre }}" />"</td>
Run Code Online (Sandbox Code Playgroud)

要显示上传的图片,我有这个错误:

An exception has been thrown during the rendering of a template ("Unable to get filename property value: "image"") in SuperlineaBundle:Instruccion:index.html.twig at line 21.
Run Code Online (Sandbox Code Playgroud)

我试图在控制器上获得帮助,它可以工作:

$helper = $this->container->get('vich_uploader.templating.helper.uploader_helper');
$path = $helper->asset($entities[0], 'image');
ladybug_dump( $path );
Run Code Online (Sandbox Code Playgroud)

显示:string(25)"/ images/uploads/video.png"

任何帮助或线索?

这是我的实体:http://pastebin.com/d8X72zK4 这是我的配置:

vich_uploader:
    db_driver: orm
    twig: true
    gaufrette: false # set to true to enable gaufrette support
    storage: vich_uploader.storage.file_system
    mappings:
        uploads:
            uri_prefix: /images/uploads
            upload_destination: %kernel.root_dir%/../web/images/uploads
            namer: ~ # specify a file namer service id for this entity, null default
            directory_namer: ~ # specify a directory namer service id for this entity, null default
            delete_on_remove: true # determines whether to delete file upon removal of entity
            inject_on_load: true # determines whether to inject a File instance upon load
        pdfs:
            uri_prefix: /images/pdf
            upload_destination: %kernel.root_dir%/../web/images/pdf
            namer: ~ # specify a file namer service id for this entity, null default
            directory_namer: ~ # specify a directory namer service id for this entity, null default
            delete_on_remove: true # determines whether to delete file upon removal of entity
            inject_on_load: true # determines whether to inject a File instance upon load
Run Code Online (Sandbox Code Playgroud)

这是我的树枝模板:...

{% for entity in entities %}
        <tr>
            <td><a href="{{ path('instruccion_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>
            <td>{{ entity.nombre }}</td>
            <td>{{ entity.foto }}<img src="<img src="{{ vich_uploader_asset(entity, 'image') } }" alt="{{ entity.nombre }}" />"</td>
            <td>{{ entity.video }}</td>
            <td>
                <ul>
                    <li>
                        <a href="{{ path('instruccion_show', { 'id': entity.id }) }}">show</a>
                    </li>
                    <li>
                        <a href="{{ path('instruccion_edit', { 'id': entity.id }) }}">edit</a>
                    </li>
                </ul>
            </td>
        </tr>
    {% endfor %}
Run Code Online (Sandbox Code Playgroud)

gav*_*_UK 6

我也有这个问题.我是由我的实体加载方式引起的.我显示的实体是另一个实体的财产.

细节:

https://github.com/dustin10/VichUploaderBundle/issues/109

https://github.com/dustin10/VichUploaderBundle/issues/28

我希望这可以帮助别人!

谢谢,加夫