Stay organized with collections Save and categorize content based on your preferences.
ImageA widget that shows a single image. For information about cropping images, see ImageCropStyle
.
Available for Google Workspace add-ons and Google Chat apps.
const image = CardService.newImage() .setAltText('A nice image') .setImageUrl('https://image.png');Detailed documentation
setAltText(altText)
Sets the alternative text of the image for accessibility. Required.
Parameters Name Type DescriptionaltText
String
The alternative text to assign to this image. Return
Image
— This object, for chaining.
setComposeAction(action, composedEmailType)
setImageUrl(url)
Sets the image to use by providing its URL or data string. Required.
The provided URL can either be a publicly accessible URL or a base64 encoded image string. To obtain the latter, you can use the following code to create an encoded image string from an image in your Google Drive, then store that string for later use with setImageUrl(url)
. This method prevents the need for your add-on to access a publicly available image URL:
// The following assumes you have the image to use in Google Drive and have its // ID. const imageBytes = DriveApp.getFileById('123abc').getBlob().getBytes(); const encodedImageURL = `data:image/jpeg;base64,${Utilities.base64Encode(imageBytes)}`; // You can store encodeImageURL and use it as a parameter to // Image.setImageUrl(url).Parameters Name Type Description
url
String
The URL address of a hosted image to use, or an encoded image string. Return
Image
— This object, for chaining.
setOnClickOpenLinkAction(action)
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-01-30 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-01-30 UTC."],[[["The `Image` widget displays a single image within Google Workspace Add-ons and Google Chat apps using a provided URL or data string."],["It allows for setting alternative text for accessibility and incorporating actions like opening links, composing emails, or triggering authorization flows when clicked."],["Developers can customize the image's behavior using various methods, including setting actions triggered on clicks and defining how the image is displayed for accessibility."],["URLs for images can be publicly accessible or base64 encoded strings, with an example provided for encoding images from Google Drive."],["A UI object can only have one action set at a time, such as opening a link, triggering an action, or composing an email, to ensure clarity and predictable behavior."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4