summaryrefslogtreecommitdiff
path: root/packages/frontend/src/scripts/upload/isWebpSupported.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/frontend/src/scripts/upload/isWebpSupported.ts')
-rw-r--r--packages/frontend/src/scripts/upload/isWebpSupported.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/packages/frontend/src/scripts/upload/isWebpSupported.ts b/packages/frontend/src/scripts/upload/isWebpSupported.ts
new file mode 100644
index 0000000000..cde8b9d785
--- /dev/null
+++ b/packages/frontend/src/scripts/upload/isWebpSupported.ts
@@ -0,0 +1,10 @@
+let isWebpSupportedCache: boolean | undefined;
+export function isWebpSupported() {
+ if (isWebpSupportedCache === undefined) {
+ const canvas = document.createElement('canvas');
+ canvas.width = 1;
+ canvas.height = 1;
+ isWebpSupportedCache = canvas.toDataURL('image/webp').startsWith('data:image/webp');
+ }
+ return isWebpSupportedCache;
+}