Get Asset MIME Type

asset.getMimeType()

Retrieve the MIME Type of a specified asset.

Syntax

1asset.getMimeType(): Promise<string>

Returns

Promise<string>

A Promise that resolves to the MIME type of the Asset

Example

1// Get Selected Element
2const el = await webflow.getSelectedElement()
3
4// Check if element is selected and its type
5if (!el || el.type !== 'Image') {
6 console.error('Please select an Image element on the canvas')
7 await webflow.notify({
8 type: 'Error',
9 message: 'Please select an Image element on the canvas',
10 })
11} else {
12 const asset = await el.getAsset() // Get Asset
13 const assetMimeType = await asset?.getMimeType() // Get Asset MIME Type
14 console.log(`Asset MIME type: ${assetMimeType}`)
15}

Designer Ability

Checks for authorization only

Designer AbilityLocaleBranchWorkflowSitemode
canAccessAssetsanyanyanyany