-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Describe the problem
Technically it is a bug, because it should work, but seeing the source code it was not implemented at all.
I'm looking for a way to set the quality of all images by default, and then crop and tint a dynamically some imported image. Obviously, this issue is geared toward having imagetools work for dynamic import first :).
To add to @flippbit list of things that doesn't work:
(#11535 (comment))
import MyImage from './path/to/your/image.jpg?enhanced&quality=80&tint=#ffaa22';
Throw an error:
Cannot find module './path/to/your/image.jpg?enhanced&quality=80' or its corresponding type declarations.ts(2307)
Sidenote:
Nuxt Img can have a global configuration to set default quality, etc: https://image.nuxt.com/get-started/configuration
*EDIT Thanks to a discord mod:
It should be implemented and is a type error:
JonasKruckenberg/imagetools#160 (comment)
sveltejs/enhanced-img type:
https://github.com/sveltejs/kit/blob/6056ba30e29ac5747c356fbf1a42dd71f2c4aa1f/packages/enhanced-img/types/ambient.d.ts
Describe the proposed solution
Implement
import MyImage from './path/to/your/image.jpg?enhanced&quality=80&tint=#ffaa22';
Alternatives considered
Make enhanced:img
accept a variable as src
for loops.
Importance
i cannot use SvelteKit without it
Additional Information
Not having this is kind of a nightmare IMO when trying to optimize images as much as possible and when using components for almost everything (Hero banner, Section's background, Image loop, galleries, etc all must use dynamic import of the images if using enhanced:img.
I didn't find a way yet on how to use it with user uploaded content since it change the image at build time.