Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/runtime/components/FileUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ export interface FileUploadProps<M extends boolean = false> extends /** @vue-ign
* @defaultValue true
*/
preview?: boolean
/**
* Preview the file (currently only `<img>` is rendered)
* When set false, only `fileIcon` is displayed
* @defaultValue true
*/
previewFile?: boolean
class?: any
ui?: FileUpload['slots']
}
Expand Down Expand Up @@ -152,7 +158,8 @@ const props = withDefaults(defineProps<FileUploadProps<M>>(), {
fileDelete: true,
layout: 'grid',
position: 'outside',
preview: true
preview: true,
previewFile: true
})
const emits = defineEmits<FileUploadEmits>()
const slots = defineSlots<FileUploadSlots<M>>()
Expand Down Expand Up @@ -200,8 +207,8 @@ const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.ui?.fileUpload |
disabled: props.disabled
}))

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

function formatFileSize(bytes: number): string {
Expand Down
Loading