From bc4d27410c4db84468fa6d0799aa7113fc7586f0 Mon Sep 17 00:00:00 2001 From: Narazaka Date: Fri, 7 Jul 2023 13:44:31 +0900 Subject: feat: webp convert @frontend (#11150) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * webp convert @frontend * 0.85 → 0.90 --------- Co-authored-by: tamaina --- packages/frontend/src/scripts/upload/isWebpSupported.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 packages/frontend/src/scripts/upload/isWebpSupported.ts (limited to 'packages/frontend/src/scripts/upload/isWebpSupported.ts') 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; +} -- cgit v1.2.3-freya