mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-28 18:00:15 +01:00
This commit is contained in:
parent
19ca676835
commit
c1200926ea
5 changed files with 50 additions and 41 deletions
15
app/src/asset/renderAssets.ts
Normal file
15
app/src/asset/renderAssets.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import {Constants} from "../constants";
|
||||
import {pathPosix} from "../util/pathName";
|
||||
|
||||
export const renderAssetsPreview = (pathString: string) => {
|
||||
const type = pathPosix().extname(pathString).toLowerCase()
|
||||
if (Constants.SIYUAN_ASSETS_IMAGE.includes(type)) {
|
||||
return `<img style="max-height: 100%" src="${pathString}">`;
|
||||
} else if (Constants.SIYUAN_ASSETS_AUDIO.includes(type)) {
|
||||
return `<audio style="max-width: 100%" controls="controls" src="${pathString}"></audio>`;
|
||||
} else if (Constants.SIYUAN_ASSETS_VIDEO.includes(type)) {
|
||||
return `<video style="max-width: 100%" controls="controls" src="${pathString}"></video>`;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue