chore: added functionality for not found vehicle images

This commit is contained in:
2024-12-23 16:20:38 +01:00
parent 61972c35e6
commit 91803d3fef
4 changed files with 39 additions and 8 deletions
+13 -1
View File
@@ -60,7 +60,12 @@
@keydown.enter="onVehicleSelect(vehicle)"
tabindex="0"
>
<img loading="lazy" width="120" :src="getThumbnailURL(vehicle.type, 'small')" />
<img
loading="lazy"
width="120"
:src="getThumbnailURL(vehicle.type, 'small')"
@error="onThumbnailImageError"
/>
<span>
<span
@@ -163,6 +168,13 @@ export default defineComponent({
methods: {
isTractionUnit,
onThumbnailImageError(e: Event) {
const el = e.target as HTMLImageElement;
if (el.src == '/images/no-vehicle-image.png') return;
el.src = '/images/no-vehicle-image.png';
},
onVehicleSelect(vehicle: IVehicle) {
if (this.store.chosenVehicle?.type === vehicle.type) this.addVehicle(vehicle);
this.previewVehicle(vehicle);