mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
494 B
25 lines
494 B
2 years ago
|
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
|