APIsChangelog
Log In

Get Asset MIME Type

asset.getMimeType()

Retrieve the MIME Type of a specified asset.

Syntax

asset.getMimeType(): Promise<string>

Returns

Promise<string>

A Promise that resolves to the MIME type of the Asset

Example

// Get Selected Element
const el = await webflow.getSelectedElement()

// Check if element is selected and its type
if (!el || el.type !== 'Image') {
  console.error('Please select an Image element on the canvas')
  await webflow.notify({
    type: 'Error',
    message: 'Please select an Image element on the canvas',
  })
} else {
  const asset = await el.getAsset() // Get Asset
  const assetMimeType = await asset?.getMimeType() // Get Asset MIME Type
  console.log(`Asset MIME type: ${assetMimeType}`)
}

Designer Ability

Checks for authorization only

Designer AbilityLocaleBranchWorkflowSitemode
canAccessAssetsanyanyanyany