Function loadImage

  • Loads an image from a given source, either a URL or an HTMLImageElement. Supports caching and handling cross-origin requests.

    Parameters

    Returns PCancelable<HTMLImageElement>

    Example

    const loaderWithoutCache = loadImage('/image.jpg');
    loaderWithoutCache.then((img) => console.log(img)).catch(() => {});

    const loaderWithCache = loadImage('/image.jpg', {
    crossOrigin: 'anonymous',
    useCache: true,
    });
    loaderWithCache.then((img) => console.log(img)).catch(() => {});