asset.getName()
asset.getName()
Retrieve name of specified asset.
Syntax
asset.getName(): Promise<string>
Returns
Promise<string>
A Promise that resolves to the name 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 assetName = await asset?.getName() // Get Asset Name
console.log(`Asset Name: ${assetName}`)
}
Designer Ability
Checks for authorization only
Designer Ability | Locale | Branch | Workflow | Sitemode |
---|---|---|---|---|
canAccessAssets | any | any | any | any |