通过HtmlService在Apps脚本中提供图像 [英] Serving images in an Apps Script through HtmlService
问题描述
当我在原型我的本地机器,我插入图像作为base64编码字符串内联,但它看起来像Caja不支持。
我发现这篇文章关于在Google云端硬盘上托管图像,这将工作为我的目的,但显然驱动器最近弃用该方法:
AppsScript-在HtmlService中使用Google云端硬盘中的图片
我没有请参阅给出文档的任何显而易见的方法,但我强烈不希望在外部服务上托管图像。
https://developers.google.com/apps-script/reference/html/
感谢您的洞察!
显示图片使用驱动器托管,将于2016年8月31日停止使用。
您可以将图像保存到您的Google驱动器,然后使用< img>
标记,并引用source属性中的图片:
< img src =https://googledrive.com/host/0B12wKjuEcjeiySkhPUTBsbW5j387M/my_image.pngheight =95%width = 95% >
请注意,您需要使用:
https://googledrive.com/host/[doc id]
其中[doc id]替换为文档ID
Can anyone help me determine the best way to host and serve an image using GAS's HtmlService? I'm writing an app that needs a basic HTML UI with two small images, and I'm trying to keep everything as encapsulated as possible.
When I was prototyping on my local machine, I inserted the images inline as base64 encoded strings, but it looks like Caja does't support that.
I found this post about hosting images on Google Drive, which would work for my purposes, but apparently Drive recently deprecated that method:
AppsScript- Using an image from Google Drive in HtmlService
I don't see any obvious way of doing this given the documentation, but I'd strongly prefer not to resort to hosting images on an external service.
https://developers.google.com/apps-script/reference/html/
Thanks for your insight!
Note that this way of displaying images uses drive hosting which will be discontinued August 31, 2016.
You can save images to your Google drive, then use the <img>
tag, and refer to the image in the source attribute:
For example:
<img src="https://googledrive.com/host/0B12wKjuEcjeiySkhPUTBsbW5j387M/my_image.png" height="95%" width="95%">
Note that you need to use:
"https://googledrive.com/host/[doc id]
where [doc id] is replaced by the document ID
Google Documentation Link - Hosting
这篇关于通过HtmlService在Apps脚本中提供图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!