asset.setAltText(altText, localeId?)
asset.setAltText(altText, localeId?)
This method sets the Alt Text for a specific Asset.
Syntax
asset.setAltText(altText: string | null; localeId?: string): Promise<null>
Parameters
- altText: string - The alt text for the Asset. If null is passed as this parameter, Webflow will set the asset alt text to "decorative."
- localeId string (optional) - The Locale ID for the Alt Text.
Returns
Promise<null>
A Promise that resolves to null
.
Example
// Get Asset by ID
const asset = await webflow.getAssetById(assetId)
console.log(asset)
if (asset) {
// Get asset URL
const originalAltText = await asset.getAltText()
await asset.setAltText(altText)
const newAltText = await asset.getAltText()
console.log(`Original Asset Alt Text: ${originalAltText}`)
console.log(`New Asset Alt Text: ${newAltText}`)
}
Designer Ability
Checks for authorization only
Designer Ability | Locale | Branch | Workflow | Sitemode |
---|---|---|---|---|
canAccessAssets | any | any | any | any |