Set Alt Text

element.setAltText(altText)

Set the Alt Text for an Image element on the canvas.

Syntax

element.setAltText(altText: string | null): Promise<null>

Parameters

  • alt text: string - The alternate text for an image

Returns

Promise<null>

A Promise that resolves to null

Example

// Get Selected Element
const el = await webflow.getSelectedElement()
// Check element type
if (el?.type === 'Image') {
// Set alt text
await el.setAltText('Descriptive alternative text for this image')
// Verify by getting the alt text
const alt = await el.getAltText()
console.log(alt)
} else {
console.error('Please select an image element')
await webflow.notify({
type: 'Error',
message: 'Please select an Image Element',
})
}

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canModifyImageElementanymaincanvasany