function fetchProxiedImage
fetchProxiedImage(
url: string,
width?: ImageWidth | null
): Promise<ProxiedImage | null>

Returns the image at url, from the cache or else from its host; null when the host answers with an error, or with anything but a raster image of 5 MB at most. With width, it comes as a WebP copy scaled down to it, or as it is when no copy can be made (scalableImage, and ffmpeg). The route checks url with isValidHttpUrl first.

Parameters

url: string
optional
width: ImageWidth | null

Return Type

Promise<ProxiedImage | null>

Throws

Error

When the host can't be reached, as fetchWithTimeout reports it.

Usage

import { fetchProxiedImage } from "api/remote/image-proxy.ts";