背景
我查看了Google中的图像,有两种方法我对使用getDescription()和getTitle()感兴趣。这两种方法都出现在我的appscript中的自动填充中,这两种方法似乎都有效。
问题
当将图像插入到Google幻灯片中时,我找不到设置图像描述和标题的方法。
这是插入图像的方法,但是没有标题或描述的参数。
currentPage.insertImage(imageUrl, left, top, width, height)
问题
当使用Google脚本将图像插入到Google幻灯片中时,如何设置图像标题和描述?
发布于 2018-07-17 14:17:14
虽然我不确定这个解决办法对你的情况是否有用,但这个答案如何?我总是使用幻灯片API来添加标题和描述,因为我在SlidesApp中找不到方法。示例脚本如下所示。在本例中,我使用了幻灯片API的batchUpdate。
示例脚本:
var id = currentPage.insertImage(imageUrl, left, top, width, height).getObjectId();
SlidesApp.getActivePresentation().saveAndClose(); // Important
var resource = {"requests": [
{"updatePageElementAltText": {
"objectId": id,
"description": "sampleDescription",
"title": "sampleTitle"
}
}]};
Slides.Presentations.batchUpdate(resource, presentationId);
var fields = {fields: "pageElements(description,objectId,title)"};
var ele = Slides.Presentations.Pages.get(presentationId, currentPage.getObjectId(), fields).pageElements;
ele.forEach(function(e){
if (e.objectId == id) {
Logger.log(e)
}
});
注意:
presentationId
和currentPage
。saveAndClose()
。参考资料:
2018年11月20日更新:
谷歌在2018年11月14日的更新中更新了幻灯片服务,并增加了几种方法来解决这个问题。
新方法允许将alt标题和alt描述添加到页面元素中。以下方法已添加到组、图像、线条、PageElement、形状、SheetsChart、表、视频和WordArt类中
https://stackoverflow.com/questions/51390578
复制相似问题