function serveImage
serveImage(
ctx: Context,
path: string,
mime: string,
cacheControl: string,
defaultWidth?: ImageWidth
): Promise<boolean>

Sends the image at path, of type mime, with cacheControl: a WebP copy at most as wide as the request's ?w= names (shared/image.ts), or as defaultWidth without one, and the image as it is when the request names no width or the copy can't be made. With ?f=compat, the copy is a JPEG, or a PNG for an image that may be transparent, which the digest's emails ask for, since not every mail client reads WebP. Every route that answers one of the site's own images ends here, so each takes both. It resolves false, having sent nothing, when the file is missing.

Parameters

ctx: Context
path: string
mime: string
cacheControl: string
optional
defaultWidth: ImageWidth

Return Type

Promise<boolean>

Usage

import { serveImage } from "api/lib/upload.ts";