Produce and use webp pictures with different sizes

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-12-11 15:27:04 +01:00
parent c8987df7af
commit 6a52ca0d91
15 changed files with 267 additions and 17 deletions

10
js/src/utils/support.ts Normal file
View File

@@ -0,0 +1,10 @@
export function supportsWebPFormat(): boolean {
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;
}