element.getAltText()

Retrieve the alt text for an Image element on the canvas. If the Image element doesn’t have alt text, the API will retrieve the alt text from the associated Asset.

Syntax

1element.getAltText(): Promise<string>

Returns

Promise<String>

A Promise that resolves to the string of alt text.

Example

1// Get Selected Element
2const el = await webflow.getSelectedElement()
3if (el?.type === 'Image') {
4 // Get alt text
5 const alt = await el.getAltText()
6 console.log(alt)
7} else {
8 console.error('Please select an image element')
9 await webflow.notify({
10 type: 'Error',
11 message: 'Please select an Image Element',
12 })
13}

Designer Ability

Checks for authorization only

Designer AbilityLocaleBranchWorkflowSitemode
canAccessAssetsanyanyanyany
Built with