mirror of
https://github.com/koreanbots/core.git
synced 2025-12-16 06:20:24 +00:00
feat: added method for check webp is available
This commit is contained in:
parent
ac4d00bf8b
commit
a6e6c575c8
@ -21,3 +21,13 @@ export function checkPerm(base: number, required: number | UserPemissionFlags):b
|
|||||||
export function makeImageURL(root:string, { format='png', size=256 }:ImageOptions):string {
|
export function makeImageURL(root:string, { format='png', size=256 }:ImageOptions):string {
|
||||||
return `${root}.${format}?size=${size}`
|
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