Class ImageItem

ImageItem

顯示圖片的版面配置項目。您可以透過 Form 存取或建立項目。

// Open a form by ID and add a new image item
var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
var 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()ImageItem建立這個項目的副本,並附加到表單末尾。
getAlignment()Alignment取得圖片的水平對齊方式。
getHelpText()String取得項目的說明文字 (有時稱為 ImageItemsPageBreakItemsSectionHeaderItems 等版面配置項目的說明文字)。
getId()Integer取得項目的專屬 ID。
getImage()Blob取得目前指派給該項目的圖片。
getIndex()Integer取得表單中所有項目的索引。
getTitle()String取得項目的標題 (在 SectionHeaderItem 中則稱為標題文字)。
getType()ItemType取得項目的類型,以 ItemType 表示。
getWidth()Integer取得圖片的寬度 (以像素為單位)。
setAlignment(alignment)ImageItem設定圖片的水平對齊方式。
setHelpText(text)ImageItem設定項目的說明文字 (有時稱為 ImageItemsPageBreakItemsSectionHeaderItems 等版面配置項目的說明文字)。
setImage(image)ImageItem設定圖片本身。
setTitle(title)ImageItem設定項目的標題 (在 SectionHeaderItem 中也稱為標題文字)。
setWidth(width)ImageItem設定圖片的寬度 (以像素為單位)。

內容詳盡的說明文件

duplicate()

建立這個項目的副本,並附加到表單末尾。

回攻員

ImageItem — 此 ImageItem 的重複項目,用於鏈結

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getAlignment()

取得圖片的水平對齊方式。

回攻員

Alignment:水平對齊

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getHelpText()

取得項目的說明文字 (有時稱為 ImageItemsPageBreakItemsSectionHeaderItems 等版面配置項目的說明文字)。

回攻員

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()

取得目前指派給該項目的圖片。

回攻員

Blob:圖片資料

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

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()

取得項目的類型,以 ItemType 表示。

回攻員

ItemType:項目的類型

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getWidth()

取得圖片的寬度 (以像素為單位)。

回攻員

Integer:寬度 (以像素為單位)

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setAlignment(alignment)

設定圖片的水平對齊方式。

參數

名稱類型說明
alignmentAlignment水平對齊

回攻員

ImageItem — 此 ImageItem,用於鏈結

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setHelpText(text)

設定項目的說明文字 (有時稱為 ImageItemsPageBreakItemsSectionHeaderItems 等版面配置項目的說明文字)。

參數

名稱類型說明
textString新的說明文字

回攻員

ImageItem — 此 ImageItem,用於鏈結

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setImage(image)

設定圖片本身。

參數

名稱類型說明
imageBlobSource圖片資料

回攻員

ImageItem — 此 ImageItem,用於鏈結

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setTitle(title)

設定項目的標題 (在 SectionHeaderItem 中也稱為標題文字)。

參數

名稱類型說明
titleString新的標題或標題文字

回攻員

ImageItem — 此 ImageItem,用於鏈結

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setWidth(width)

設定圖片的寬度 (以像素為單位)。只能設定圖片的寬度。系統會自動設定高度,以維持圖片的比例。

參數

名稱類型說明
widthInteger寬度 (以像素為單位)

回攻員

ImageItem — 此 ImageItem,用於鏈結

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms