Last active
January 16, 2019 17:49
-
-
Save daliborgogic/27c68c1cfb29b639ea48f7964cbb6d9c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 imgOops id => { | |
const images = require.context('@/static/img/', true, /\.(png|jpe?g|svg)$/) | |
const obj = {} | |
images.keys().forEach(key => { | |
const code = key.split('./').pop() | |
.substring(0, key.length - 6) // remove extension | |
obj[code] = images(key) | |
}) | |
return obj[id] | |
? obj[id] | |
: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7' | |
} | |
export default imgOops |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment