Skip to content
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

Upgrade to 11: Custom optimizer ignored #3566

Closed
korridor opened this issue Mar 12, 2024 · 4 comments
Closed

Upgrade to 11: Custom optimizer ignored #3566

korridor opened this issue Mar 12, 2024 · 4 comments

Comments

@korridor
Copy link
Contributor

korridor commented Mar 12, 2024

I use a custom optimizer and register this optimizer in the config media-library.image_optimizers.
Since the major 11 upgrade, the custom optimizer does not get called at all. If I add logs to the canHandle and getCommand function, nothing happens. If I downgrade, it works again, without changing anything else.


I debugged the problem a bit, and it looks to me like the problem is somewhere here:

The laravel-medialibrary only uses the image_optimizers config here to create the OptimizerChainFactory:

$optimizerChain = OptimizerChainFactory::create(config('media-library.image_optimizers'));

In the OptimizerChainFactory (https://github.com/spatie/image-optimizer/blob/02e2717c31334646f00a0e25cf5edbf41bd20ac3/src/OptimizerChainFactory.php#L15) the $config is being used, but it ignores custom optimizers, since the optimizers are redefined here. (https://github.com/spatie/image-optimizer/blob/02e2717c31334646f00a0e25cf5edbf41bd20ac3/src/OptimizerChainFactory.php#L35)

@patinthehat
Copy link
Collaborator

@korridor We'd be happy to accept a PR that fixes this! 👍

@timvandijck
Copy link
Member

A PR with just a failing test would be welcome too (sounds like a good first issue).

@0xb4lint
Copy link
Contributor

0xb4lint commented May 3, 2024

I've made a PR for this issue: spatie/image-optimizer#216

@timvandijck
Copy link
Member

I just merged and published the PR, thank you!

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

No branches or pull requests

4 participants