<template>
  <img
    v-if='!error || fallback'
    :src='error ? fallback : src'
    @error='onImgError'>
</template>

<script>
export default {
  props: {
    src: {
      type: String,
      default: '',
    },
    fallback: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      error: false,
    }
  },
  methods: {
    onImgError(event) {
      event.preventDefault()
      event.stopPropagation()
      this.error = true
    },
  },
}
</script>

<style lang='postcss'>
.module-image {
  /* place your css here */
}
</style>
