Skip to content

[LazyImage] - Issue between ux-lazy-image and intervention/image (ImageManager::__construct(), 0 passed) #1670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
a-lebailly opened this issue Apr 1, 2024 · 2 comments

Comments

@a-lebailly
Copy link

Hello, I have a problem when I try to use UX Lazy Image with BlurHash.

When I try to execute this code in one of my templates (according to symfony example ux) :

<img
    src="{{ data_uri_thumbnail('build/images/logo.png', 40, 30) }}"
    data-controller="symfony--ux-lazy-image--lazy-image"
    data-symfony--ux-lazy-image--lazy-image-src-value="{{ asset('build/images/logo.png') }}"
    alt="A blurhash image that is replaced by the real image on load"
    width="578"
    height="275"
    style="border-radius: 5px;"
>

I get the following error message :

An exception has been thrown during the rendering of a template ("To use the Blurhash feature, install intervention/image.").

So I install intervention/image according to the message with composer require intervention/image (version 3.5).
But I get another error message :

Too few arguments to function Intervention\Image\ImageManager::__construct(), 0 passed in /Users/.../symfony-app/var/cache/dev/ContainerGHlcxB8/App_KernelDevDebugContainer.php on line 1525 and exactly 1 expected

After looking through the App_KernelDevDebugContainer file, I found this line :

$instance->addExtension(new \Symfony\UX\LazyImage\Twig\BlurHashExtension(new \Symfony\UX\LazyImage\BlurHash\BlurHash(new \Intervention\Image\ImageManager())));

ImageManager is instantiated without any parameter, but requires one :

public function __construct(string|DriverInterface $driver)
{
    $this->driver = $this->resolveDriver($driver);
}

https://github.com/Intervention/image/blob/3.5.0/src/ImageManager.php

If anyone has any ideas on how to solve this problem, I'd love to hear from you.
I'll investigate for more details.

@kbond
Copy link
Member

kbond commented Apr 1, 2024

Can you try using intervention v2? V3 is not yet supported (#1465).

@a-lebailly
Copy link
Author

a-lebailly commented Apr 1, 2024

Can you try using intervention v2? V3 is not yet supported (#1465).

@kbond Sorry, I hadn't seen this issue.
I went back to the latest v2 (2.7.2) and it works fine.

Thank's for your help ! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants