Skip to content

Commit

Permalink
add error handling for image component (directus#8097)
Browse files Browse the repository at this point in the history
  • Loading branch information
azrikahar committed Sep 17, 2021
1 parent 05eeb9a commit f7954a1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions app/src/displays/image/image.vue
@@ -1,6 +1,13 @@
<template>
<v-icon v-if="imgError" name="" />
<img v-else-if="src" :src="src" role="presentation" :alt="value && value.title" :class="{ circle }" />
<v-icon v-if="imageError" name="image" />
<img
v-else-if="src"
:src="src"
role="presentation"
:alt="value && value.title"
:class="{ circle }"
@error="imageError = true"
/>
<value-null v-else />
</template>

Expand Down Expand Up @@ -29,15 +36,15 @@ export default defineComponent({
},
},
setup(props) {
const imgError = ref(false);
const imageError = ref(false);
const src = computed(() => {
if (props.value === null) return null;
const url = getRootPath() + `assets/${props.value.id}?key=system-small-cover`;
return addTokenToURL(url);
});
return { src, imgError };
return { src, imageError };
},
});
</script>
Expand Down

0 comments on commit f7954a1

Please sign in to comment.