Symfony 6 Liipimagine imagine_filter doesn't work

335 views Asked by At

I am trying to use the bundle Liipimagine in a Symfony 6 project for the first time and I have a problem. I created a filter in the liip_imagine.yaml

liip_imagine:
    # valid drivers options include "gd" or "gmagick" or "imagick"
    driver: "gd"

    filter_sets:
        livres:
            quality: 75
            filters: 
                fixed: 
                    width: 120
                    height: 90

When I want to use my filter, if in my twig view I use this syntax :

<img src="{{ asset('assets/images/photographier.jpg') | imagine_filter('livres') }}" alt="photo appareil photo" class="rounded-3 mb-2">

the picture is well display

But if I use this syntax for another image :

<img class="img-fluid" src="/uploads/images/{{ exposition.image1|imagine_filter('livres') }}" alt="photo pour l'exposition {{ exposition.titre }}">

it doesn't work. Nothing is displayed and I have this error in the console : Failed to load resource: the server responded with a status of 404 ()

If I don't use the imagine_filter the two pictures are displayed.

I think the problem comes from the way I integrate the imagine_filter in the but I can't find a solution. Does somebody have an idea ?

Thanks for any help

1

There are 1 answers

1
Oscar On

There is a typo in the src attribute. you should write :

src="{{'relative/path/to/your/image'|imagine_filter('livres') }}"

If your image is uploaded through your app, I highly recommend you to use vich uploader.

With vich bundle the src attribute will be :

src="{{ vich_uploader_asset(exposition, 'imageFile') | imagine_filter("livres")}}"