Skip to content

Instantly share code, notes, and snippets.

@daliborgogic
Last active January 16, 2019 17:49
Show Gist options
  • Save daliborgogic/27c68c1cfb29b639ea48f7964cbb6d9c to your computer and use it in GitHub Desktop.
Save daliborgogic/27c68c1cfb29b639ea48f7964cbb6d9c to your computer and use it in GitHub Desktop.
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