element.setAltText(altText)

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

Syntax

1element.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

1// Get Selected Element
2const el = await webflow.getSelectedElement()
3
4// Check element type
5if (el?.type === 'Image') {
6 // Set alt text
7 await el.setAltText('Descriptive alternative text for this image')
8
9 // Verify by getting the alt text
10 const alt = await el.getAltText()
11 console.log(alt)
12} else {
13 console.error('Please select an image element')
14 await webflow.notify({
15 type: 'Error',
16 message: 'Please select an Image Element',
17 })
18}

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canModifyImageElementanymaincanvasany
Built with