vich uploader and easy admin images not showing

3.1k views Asked by At

I'm following the tutorial from (https://symfony.com/doc/master/bundles/EasyAdminBundle/integration/vichuploaderbundle.html)

I was able to upload the image, but it´s not appearing in the list view of easy-admin.

It goes like this:

#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' }

Below are the path to upload the file:

#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

The file and the images are being uploaded to the folder:

enter image description here


but aren't being displayed inside easy admin view

enter image description here

It´s my first time using Symfony all these related techniques, so I´m a little lost here.

2

There are 2 answers

2
famas23 On BEST ANSWER

You should put your images under public folder, try this mapping configuration:

   manchete_images:
            uri_prefix:         '%app.path.manchete_images%'
            upload_destination: '%kernel.project_dir%/public/%app.path.manchete_images%'
0
Adriel Werlich On

Yes, thanks to @Ahmed suggestion, it´s showing now... thought the uri_prefix should contain single quote marks, otherwise exception occurs...

like this:

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

enter image description here

thanks again...