Last active
November 7, 2024 09:16
-
-
Save Pigamo/6ad9d769a23bbdc07a9ef6f7226cbb55 to your computer and use it in GitHub Desktop.
Imports multiple images from a folder using Vite globs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const gallery = Object.values(import.meta.glob('@assets/*.{png,jpg,jpeg,PNG,JPEG}', { eager: true, as: 'url' })) |
Author
Pigamo
commented
Feb 24, 2023
via email
Hmm, it’s been a while since I’ve used this.
I had some issues with dynamically loaded imgs.
Keep testing it and let me know. This was used in conjunction with
image-tools to resize and convert to next-gen formats. It’s possible there
is a suffix needed like .url or something.
Console the urls in build see if they come up. I’ll try to test as well.
…On Fri, Feb 24, 2023 at 10:19 AM Tim ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
I mean, it does work on dev, but as soon as I build, image are bundled but
the href to the image is not correct
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/6ad9d769a23bbdc07a9ef6f7226cbb55#gistcomment-4482579>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AN3M4JJNAQ7COMSD7KFJD2TWZDGQ7BFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTCMZRGY3TCMBVU52HE2LHM5SXFJTDOJSWC5DF>
.
You are receiving this email because you authored the thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
The issue is the path to the image, I've posted a question on Vite's discussion thing on GitHub .
If you find or remember anything, tell me!
Thank you dude
hey looks like you guys figured it out! maybe i can update the gist to
reflect it. I realized too it wasn’t very comprehensive in it’s import
allowance.
…On Fri, Feb 24, 2023 at 12:15 PM Tim ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
The issue is the path to the image, I've posted a question on Vite's
discussion thing on GitHub
<vitejs/vite#12191> .
If you find or remember anything, tell me!
Thank you dude
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/6ad9d769a23bbdc07a9ef6f7226cbb55#gistcomment-4482736>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AN3M4JMZMDY66XOS6RRFGRLWZDUCXBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTCMZRGY3TCMBVU52HE2LHM5SXFJTDOJSWC5DF>
.
You are receiving this email because you authored the thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
Thanks for asking the right questions. I updated the gist to reflect the answer!
The issue is the path to the image, I've posted a question on Vite's discussion thing on GitHub . If you find or remember anything, tell me! Thank you dude
Thanks @mkxto
Does anyone know how to use this in SvelteKit?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment