diff options
author | Chocobozzz <me@florianbigard.com> | 2021-09-08 10:10:51 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-09-08 10:16:39 +0200 |
commit | 0ea2f79d45b301fcd660efc894469a99b2239bf6 (patch) | |
tree | f100945f86cdcac37cf953b5af0c8fd1a3c8daad /client/src/root-helpers | |
parent | 4546d92e40a253047d9648c0749578429dce1c3f (diff) | |
download | PeerTube-0ea2f79d45b301fcd660efc894469a99b2239bf6.tar.gz PeerTube-0ea2f79d45b301fcd660efc894469a99b2239bf6.tar.zst PeerTube-0ea2f79d45b301fcd660efc894469a99b2239bf6.zip |
Safer image preview
Diffstat (limited to 'client/src/root-helpers')
-rw-r--r-- | client/src/root-helpers/images.ts | 13 | ||||
-rw-r--r-- | client/src/root-helpers/index.ts | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/client/src/root-helpers/images.ts b/client/src/root-helpers/images.ts new file mode 100644 index 000000000..fb229ce6d --- /dev/null +++ b/client/src/root-helpers/images.ts | |||
@@ -0,0 +1,13 @@ | |||
1 | function imageToDataURL (input: File | Blob) { | ||
2 | return new Promise<string>(res => { | ||
3 | const reader = new FileReader() | ||
4 | |||
5 | reader.onerror = err => console.error('Cannot read input file.', err) | ||
6 | reader.onloadend = () => res(reader.result as string) | ||
7 | reader.readAsDataURL(input) | ||
8 | }) | ||
9 | } | ||
10 | |||
11 | export { | ||
12 | imageToDataURL | ||
13 | } | ||
diff --git a/client/src/root-helpers/index.ts b/client/src/root-helpers/index.ts index d62f07f9e..63d55d7ef 100644 --- a/client/src/root-helpers/index.ts +++ b/client/src/root-helpers/index.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | export * from './users' | 1 | export * from './users' |
2 | export * from './bytes' | 2 | export * from './bytes' |
3 | export * from './images' | ||
3 | export * from './peertube-web-storage' | 4 | export * from './peertube-web-storage' |
4 | export * from './utils' | 5 | export * from './utils' |
5 | export * from './plugins-manager' | 6 | export * from './plugins-manager' |