顯示圖片的版面配置項目。您可以透過 Form 存取或建立項目。
// Open a form by ID and add a new image item const form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); const img = UrlFetchApp.fetch('https://www.google.com/images/srpr/logo4w.png'); form.addImageItem() .setTitle('Google') .setHelpText('Google Logo') // The help text is the image description .setImage(img);
方法
| 方法 | 傳回類型 | 簡短說明 |
|---|---|---|
duplicate() | Image | 建立這個項目的副本,並附加到表單結尾。 |
get | Alignment | 取得圖片的水平對齊方式。 |
get | String | 取得項目的說明文字 (有時稱為版面配置項目的說明文字,例如 Image、Page 和 Section)。 |
get | Integer | 取得項目的專屬 ID。 |
get | Blob | 取得目前指派給項目的圖片。 |
get | Integer | 取得表單中所有項目中的項目索引。 |
get | String | 取得項目的標題 (如果是 Section,有時稱為標頭文字)。 |
get | Item | 取得項目的類型,以 Item 表示。 |
get | Integer | 取得圖片的寬度 (以像素為單位)。 |
set | Image | 設定圖片的水平對齊方式。 |
set | Image | 設定項目的說明文字 (有時稱為版面配置項目的說明文字,例如 Image、Page 和 Section)。 |
set | Image | 設定圖片本身。 |
set | Image | 設定項目的標題 (如果是 Section,有時稱為標頭文字)。 |
set | Image | 以像素為單位設定圖片寬度。 |
內容詳盡的說明文件
duplicate()
getAlignment()
getHelpText()
取得項目的說明文字 (有時稱為版面配置項目的說明文字,例如 ImageItems、PageBreakItems 和 SectionHeaderItems)。
回攻員
String:項目的說明文字
授權
使用這個方法的指令碼需要下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getId()
取得項目的專屬 ID。
回攻員
Integer:商品的 ID
授權
使用這個方法的指令碼需要下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getImage()
getIndex()
取得表單中所有項目中的項目索引。
回攻員
Integer:項目的索引
授權
使用這個方法的指令碼需要下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getTitle()
取得項目的標題 (如果是 SectionHeaderItem,有時稱為標頭文字)。
回攻員
String:項目的標題或標頭文字
授權
使用這個方法的指令碼需要下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getType()
getWidth()
取得圖片寬度 (以像素為單位)。
回攻員
Integer:寬度 (以像素為單位)
授權
使用這個方法的指令碼需要下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
setAlignment(alignment)
setHelpText(text)
設定項目的說明文字 (有時稱為版面配置項目的說明文字,例如 ImageItems、PageBreakItems 和 SectionHeaderItems)。
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
text | String | 新的說明文字 |
回攻員
授權
使用這個方法的指令碼需要下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
setImage(image)
設定圖片本身。
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
image | Blob | 圖片資料 |
回攻員
授權
使用這個方法的指令碼需要下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
setTitle(title)
設定項目的標題 (如果是 SectionHeaderItem,有時稱為標頭文字)。
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
title | String | 新標題或標頭文字 |
回攻員
授權
使用這個方法的指令碼需要下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms