mirror of
https://github.com/koreanbots/core.git
synced 2025-12-15 14:10:22 +00:00
feat: added method for check webp is available
This commit is contained in:
parent
ac4d00bf8b
commit
a6e6c575c8
@ -20,4 +20,14 @@ export function checkPerm(base: number, required: number | UserPemissionFlags):b
|
||||
|
||||
export function makeImageURL(root:string, { format='png', size=256 }:ImageOptions):string {
|
||||
return `${root}.${format}?size=${size}`
|
||||
}
|
||||
|
||||
export function supportsWebP() {
|
||||
const elem = document.createElement('canvas')
|
||||
if (elem.getContext && elem.getContext('2d')) {
|
||||
// was able or not to get WebP representation
|
||||
return elem.toDataURL('image/webp').indexOf('data:image/webp') == 0
|
||||
}
|
||||
// very old browser like IE 8, canvas not supported
|
||||
return false
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user