mirror of https://github.com/nocodb/nocodb
Wing-Kam Wong
2 years ago
1 changed files with 24 additions and 0 deletions
@ -0,0 +1,24 @@
|
||||
const useAttachment = () => { |
||||
const { appInfo } = useGlobal() |
||||
|
||||
const getAttachmentSrc = (item: Record<string, any>) => { |
||||
if (item.data) { |
||||
return item.data |
||||
} else if (item.path) { |
||||
return `${appInfo.value.ncSiteUrl}/${item.path}` |
||||
} |
||||
return item.url |
||||
} |
||||
|
||||
const showFallback = (evt: any, item: Record<string, any>) => { |
||||
evt.onerror = null |
||||
evt.target.src = item.url |
||||
} |
||||
|
||||
return { |
||||
getAttachmentSrc, |
||||
showFallback, |
||||
} |
||||
} |
||||
|
||||
export default useAttachment |
Loading…
Reference in new issue