首页 文章

vich uploader和简单的管理员图像没有显示

提问于
浏览
1

我有问题,如果有人知道发生了什么,请帮助,我正在遵循教程(https://symfony.com/doc/master/bundles/EasyAdminBundle/integration/vichuploaderbundle.html

我能够上传图像,但它没有出现在easy-admim的列表视图中

它是这样的:

#easy_admin.yaml
easy_admin:
  entities:
    Manchete:
      class:  App\Entity\Manchete
      form:
        fields:
          - titulo
          - descricao
          - link
          - {  property: 'arquivoDaImagem', type: 'vich_image', base_path: '%app.path.manchete_images%',
               help: 'selecione uma imagem para a manchete',
                , label: 'Imagem da manchete', template: 'vich_uploader_image.html.twig' }



      # ...
      list:
        fields:
        - titulo
        - descricao
        - link
        - {  property: 'imagem', template: 'vich_uploader_image.html.twig' }
      # ...
      show:
        fields:
        - titulo
        - descricao
        - link
        - {  property: 'imagem', template: 'vich_uploader_image.html.twig' }

bellow是上传文件的路径 - >

#vich_uploader.yalm
vich_uploader:
    db_driver: orm

    mappings:
        manchete_images:
            uri_prefix: '%app.path.manchete_images%' 
            upload_destination: '%kernel.project_dir%/%app.path.manchete_images%'

#services.yaml
parameters:
    locale: 'en'
    app.path.manchete_images: /uploads/images/manchetes

文件和图像正在上传到文件夹:

enter image description here


但不会显示在简单的管理视图中

enter image description here

所以这是我第一次使用symfony所有这些相关的技术,所以我在这里有点迷失...

提前感谢任何回复......

2 回答

  • 0

    你应该把你的图像放在 public 文件夹下,试试这个映射配置:

    manchete_images:
                uri_prefix:         '%app.path.manchete_images%'
                upload_destination: '%kernel.project_dir%/public/%app.path.manchete_images%'
    
  • 3

    是的,感谢@Ahmed的建议,它现在显示...认为uri_prefix应该包含单引号,否则会发生异常......

    像这样:

    manchete_images:
                uri_prefix:  '%app.path.manchete_images%'   
                upload_destination:  '%kernel.project_dir%/public/%app.path.manchete_images%'
    

    enter image description here

    再次感谢...

相关问题