Class ImageComponent

  • The ImageComponent is an image component that can be added to grid items.

  • This component is available for Google Workspace add-ons and Google Chat apps.

  • Key methods for the ImageComponent include setting alt text, border style, crop style, and image URL.

ImageComponent

An image component that can be added to grid items.

Available for Google Workspace add-ons and Google Chat apps.

constImageComponent=CardService.newImageComponent()
.setImageUrl('http://imageurl.ca')
.setAltText('YOUR ALT TEXT')
.setCropStyle(CardService.newImageCropStyle())
.setBorderStyle(CardService.newBorderStyle());

Methods

MethodReturn typeBrief description
setAltText(altText) ImageComponent Sets the alternative text of the image.
setBorderStyle(borderStyle) ImageComponent Sets the border style applied to the image.
setCropStyle(imageCropStyle) ImageComponent Sets the crop style for the image.
setImageUrl(url) ImageComponent Sets the URL of the image.

Detailed documentation

setAltText(altText)

Sets the alternative text of the image.

Parameters

NameTypeDescription
altTextStringThe alt_text to set for the image.

Return

ImageComponent — This object, for chaining.


setBorderStyle(borderStyle)

Sets the border style applied to the image.

Parameters

NameTypeDescription
borderStyleBorderStyle The BorderStyle object to apply.

Return

ImageComponent — This object, for chaining.


setCropStyle(imageCropStyle)

Sets the crop style for the image.

Parameters

NameTypeDescription
imageCropStyleImageCropStyle The ImageCropStyle object to apply.

Return

ImageComponent — This object, for chaining.


setImageUrl(url)

Sets the URL of the image.

Parameters

NameTypeDescription
urlStringThe URL.

Return

ImageComponent — This object, for chaining.

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.