Restez organisé à l'aide des collections Enregistrez et classez les contenus selon vos préférences.
Composant Image
Composant Image pouvant être ajouté aux éléments de grille.
Disponible pour les modules complémentaires Google Workspace et les applications Google Chat.
constImageComponent=CardService.newImageComponent().setImageUrl('http://imageurl.ca').setAltText('YOUR ALT TEXT').setCropStyle(CardService.newImageCropStyle()).setBorderStyle(CardService.newBorderStyle());
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/26 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/07/26 (UTC)."],[[["\u003cp\u003eThe \u003ccode\u003eImageComponent\u003c/code\u003e allows you to add images to grid items within Google Workspace Add-ons and Google Chat apps.\u003c/p\u003e\n"],["\u003cp\u003eYou can customize the image with methods to set the alternative text, border style, crop style, and URL.\u003c/p\u003e\n"],["\u003cp\u003eAll customization methods (\u003ccode\u003esetAltText\u003c/code\u003e, \u003ccode\u003esetBorderStyle\u003c/code\u003e, \u003ccode\u003esetCropStyle\u003c/code\u003e, \u003ccode\u003esetImageUrl\u003c/code\u003e) return the \u003ccode\u003eImageComponent\u003c/code\u003e object for chaining multiple operations.\u003c/p\u003e\n"],["\u003cp\u003eAn \u003ccode\u003eImageComponent\u003c/code\u003e can be created using \u003ccode\u003eCardService.newImageComponent()\u003c/code\u003e, which provides methods for customization.\u003c/p\u003e\n"]]],[],null,["ImageComponent\n\nAn image component that can be added to grid items.\n\nAvailable for Google Workspace add-ons and Google Chat apps.\n\n```javascript\nconst ImageComponent = CardService.newImageComponent()\n .setImageUrl('http://imageurl.ca')\n .setAltText('YOUR ALT TEXT')\n .setCropStyle(CardService.newImageCropStyle())\n .setBorderStyle(CardService.newBorderStyle());\n``` \n\nMethods\n\n| Method | Return type | Brief description |\n|---------------------------------------------------------------|---------------------|---------------------------------------------|\n| [setAltText(altText)](#setAltText(String)) | [ImageComponent](#) | Sets the alternative text of the image. |\n| [setBorderStyle(borderStyle)](#setBorderStyle(BorderStyle)) | [ImageComponent](#) | Sets the border style applied to the image. |\n| [setCropStyle(imageCropStyle)](#setCropStyle(ImageCropStyle)) | [ImageComponent](#) | Sets the crop style for the image. |\n| [setImageUrl(url)](#setImageUrl(String)) | [ImageComponent](#) | Sets the URL of the image. |\n\nDetailed documentation \n\n`set``Alt``Text(altText)` \nSets the alternative text of the image.\n\nParameters\n\n| Name | Type | Description |\n|-------------|----------|------------------------------------|\n| `alt``Text` | `String` | The alt_text to set for the image. |\n\nReturn\n\n\n[ImageComponent](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n`set``Border``Style(borderStyle)` \nSets the border style applied to the image.\n\nParameters\n\n| Name | Type | Description |\n|-----------------|-----------------------------------------------------------------|----------------------------------|\n| `border``Style` | [BorderStyle](/apps-script/reference/card-service/border-style) | The BorderStyle object to apply. |\n\nReturn\n\n\n[ImageComponent](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n`set``Crop``Style(imageCropStyle)` \nSets the crop style for the image.\n\nParameters\n\n| Name | Type | Description |\n|----------------------|------------------------------------------------------------------------|-------------------------------------|\n| `image``Crop``Style` | [ImageCropStyle](/apps-script/reference/card-service/image-crop-style) | The ImageCropStyle object to apply. |\n\nReturn\n\n\n[ImageComponent](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n`set``Image``Url(url)` \nSets the URL of the image.\n\nParameters\n\n| Name | Type | Description |\n|-------|----------|-------------|\n| `url` | `String` | The URL. |\n\nReturn\n\n\n[ImageComponent](#) --- This object, for chaining."]]