Replies: 3 comments 1 reply
-
Great idea! This didn't cross my mind, but now that you mentioned it, why not! import { src, width } from "example.jpg?metadata"
import srcset from "example.jpg?width=500;700&srcset"
const combined = `${src} ${width}w, ${srcset} ` |
Beta Was this translation helpful? Give feedback.
-
Though not critical, this could be nice with Vite glob import, save a bit of code duplication. It would let me do this const ImageItems : Record<string, string> = import.meta.glob([
'./gallery/*.png', './gallery/*.jpg',
], {
eager: true,
import: 'default',
query: {
galleryimg: true // ?w=original;640;160
}
})
Object.entries(ImageItems).map((item) => {
// original image is item[1][0]
}) While right now I have to do this: const ImageItems : Record<string, string> = import.meta.glob([
'./gallery/*.png', './gallery/*.jpg',
], {
eager: true,
import: 'default',
query: {
galleryimg: true // ?w=640;160
}
})
const OriginalImages : Record<string, string> = import.meta.glob([
'./gallery/*.png', './gallery/*.jpg',
], {
eager: true,
import: 'default',
})
Object.entries(ImageItems).map((item) => {
// original image is OriginalImages[item[0]]
}) |
Beta Was this translation helpful? Give feedback.
-
You can do |
Beta Was this translation helpful? Give feedback.
-
Hi, is there a special value for the
width
directive so that it uses the original size of the image?The use case is format conversion, where I'd like to generate a
webp
version of the image at its full resolution as well as a smaller version.For example:
Background 📜
I'm playing around trying to replace a Jekyll setup I had where I was using ImageMagick to generate smaller versions of large images, for use in mobile devices.
An example
picture
tag:Beta Was this translation helpful? Give feedback.
All reactions