-
-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
What problem does this feature solve?
Basically to convert every image to webp (certain SEO use cases) or avif with cleaner and more practical code:
You can write:
conversion: [
{ from: '*', to: 'webp' },
{ from: 'JPG', to: 'jpeg' },
],Instead of:
conversion: [
{ from: 'jpeg', to: 'webp' },
{ from: 'png', to: 'webp' },
... // All the other formats you use
{ from: 'JPG', to: 'jpeg' },
],Not really integral, but nice to have, down to make the pr if approved.
What does the proposed API look like?
So, right now it matches the exact extension:
const userConversion = this.options.conversion.find(
(item) => item.from === ext,
);You can also afterwards check whether or not there is a *
const userConversion = this.options.conversion.find(
(item) => item.from === ext,
) ?? this.options.conversion.find(
(item) => item.from === '*',
);Or, you could also make a matcher map on creation of the ImageProcessor object, but since there aren't realistically a large abundance of options, id say that an extra find call is fine for performance.
Metadata
Metadata
Assignees
Labels
No labels