Skip to content

Commit 87a3a25

Browse files
committed
404 Image error
1 parent dd01752 commit 87a3a25

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

client/src/assets/404-image.png

12.8 KB
Loading

client/src/components/cards/DatasetCard.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="card mb-4 box-shadow">
66

77
<!-- Display Image -->
8-
<img @click="onImageClick" :src="imageUrl" class="card-img-top" style="width: 100%; display: block;">
8+
<img @click="onImageClick" :src="imageUrl" class="card-img-top" @error="imageError = true" style="width: 100%; display: block;">
99

1010
<!-- Card Body -->
1111
<div class="card-body">
@@ -157,9 +157,11 @@ export default {
157157
},
158158
data() {
159159
return {
160+
imageError: false,
160161
selectedCategories: [],
161162
defaultMetadata: this.dataset.default_annotation_metadata,
162163
noImageUrl: require("@/assets/no-image.png"),
164+
notFoundImageUrl: require("@/assets/404-image.png"),
163165
sharedUsers: this.dataset.users
164166
};
165167
},
@@ -229,11 +231,14 @@ export default {
229231
return 100 * (this.dataset.numberAnnotated / this.dataset.numberImages);
230232
},
231233
imageUrl() {
234+
if (this.imageError) {
235+
return this.notFoundImageUrl;
236+
}
232237
if (this.dataset.numberImages > 0) {
233238
return "/api/image/" + this.dataset.first_image_id + "?width=250";
234-
} else {
235-
return this.noImageUrl;
236239
}
240+
241+
return this.noImageUrl;
237242
},
238243
listCategories() {
239244
let list = [];

0 commit comments

Comments
 (0)