Skip to content
12 changes: 10 additions & 2 deletions src/runtime/components/FileUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ export interface FileUploadProps<M extends boolean = false> extends /** @vue-ign
* @IconifyIcon
*/
fileIcon?: IconProps['name']
/**
* Preview the file (currently only `<img>` is rendered)
* When set false, only `fileIcon` is displayed
* @defaultValue true
*/
fileImage?: boolean
/**
* Configure the delete button for the file.
* When `layout` is `grid`, the default is `{ color: 'neutral', variant: 'solid', size: 'xs' }`{lang="ts-type"}
Expand Down Expand Up @@ -154,7 +160,8 @@ const props = withDefaults(defineProps<FileUploadProps<M>>(), {
fileDelete: true,
layout: 'grid',
position: 'outside',
preview: true
preview: true,
fileImage: true
Comment thread
mdotme marked this conversation as resolved.
})
const emits = defineEmits<FileUploadEmits>()
const slots = defineSlots<FileUploadSlots<M>>()
Expand Down Expand Up @@ -203,7 +210,8 @@ const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.ui?.fileUpload |
disabled: props.disabled
}))

function createObjectUrl(file: File): string {
function createObjectUrl(file: File): string | undefined {
if (!props.fileImage) return undefined
return URL.createObjectURL(file)
}

Expand Down
Loading