Closed mseele closed 2 years ago
Unfortunately, Vite currently does not support passing query parameters in glob imports, which would be an automatic way to generate a similar structure to the map in your example. It might add it in the future, perhaps you can suggest it as a feature request in Vite.
This plugin does provide a programmatic API that can be used directly:
const image = await images.api.resolveImage('@/assets/events/${imageName}`, { preset: 'full' })
For certain use cases this is a reasonable approach, such as when using extendFrontmatter
in îles.
Moving this to discussions, feel free to ask additional questions.
Is there any possibility to load dynamic images? I have the following use case: I load a list of events from my headless cms. All events have an attribute title image that is named like an image i have in my assets folder. Now i want to use vite-plugin-image-presets with the picture vue sfc and the image described in the event attribute. Is there any pattern i can use to do this?
My workaround is a sfc called
DynamicPicture
that looks like this:It works. But i need to add a line of code every time i add a new event image into the assets directory (what happens sometimes).