mediaTypeOfPath
Finds the media type of a file from the extension of its path or URL: images, fonts, web
documents, scripts and styles, data, audio and video. Case is ignored, and a query string or
fragment after the path is skipped. Pass it where a server or a Blob needs a Content-Type.
Available since v3.1.10
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path | string | A file path or URL |
Returns
Section titled “Returns”string | undefined — The media type ('image/webp', …), or undefined for an unknown or missing extension
Examples
Section titled “Examples”Content-Type from a path
Section titled “Content-Type from a path”Case and a query string are ignored.
