Files
mixtape/zero.Backoffice.UI/app/components/ui-thumbnail.vue
T

41 lines
775 B
Vue
Raw Normal View History

2021-12-09 14:18:38 +01:00
<template>
2021-12-09 14:36:30 +01:00
<img v-if="media && !hasError" :src="src" @error="onError" />
<span v-else><slot></slot></span>
2021-12-09 14:18:38 +01:00
</template>
<script lang="ts">
import { defineComponent } from 'vue';
2021-12-13 15:17:47 +01:00
import { paths } from '../options';
2021-12-09 14:18:38 +01:00
export default defineComponent({
name: 'uiThumbnail',
props: {
media: {
type: String,
required: true
},
size: {
type: String,
2021-12-13 15:17:47 +01:00
default: 'thumb'
2021-12-09 14:18:38 +01:00
}
},
2021-12-09 14:36:30 +01:00
data: () => ({
hasError: false
}),
2021-12-09 14:18:38 +01:00
computed: {
src()
{
2022-01-04 12:58:42 +01:00
return this.media ? (paths.api.replace('{app}', 'hofbauer') + '/backoffice/ui/thumbnail/' + this.media + '-' + this.size + '.tmp') : null;
2021-12-09 14:36:30 +01:00
},
onError(ev)
{
this.hasError = true;
2021-12-09 14:18:38 +01:00
}
}
});
</script>