first commit
Some checks failed
Build / run (push) Has been cancelled

This commit is contained in:
maher
2025-10-29 11:42:25 +01:00
commit 703f50a09d
4595 changed files with 385164 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
/**
* Load image avoiding xhr/fetch CORS issues. Server status can't be obtained this way
* unfortunately, so this uses "naturalWidth" to determine if the image has been loaded. By
* default, it checks if it is at least 1px.
*/
export const loadImage = (
src: string,
minWidth = 1
): Promise<HTMLImageElement> =>
new Promise((resolve, reject) => {
const image = new Image();
const handler = () => {
// @ts-expect-error
delete image.onload;
// @ts-expect-error
delete image.onerror;
if (image.naturalWidth >= minWidth) {
resolve(image);
} else {
reject('Could not load youtube image');
}
};
Object.assign(image, {onload: handler, onerror: handler, src});
});