如何使用< img src>在Google Apps脚本中 [英] How to use <img src > in google apps script

查看:93
本文介绍了如何使用< img src>在Google Apps脚本中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用src属性在Google Apps脚本中显示图像.我把文件夹的ID和路径.但是图像无法显示.我在这里共享了文件夹.

I want to display the image in a google apps script using src attribute. I put the folder id and the path. But the image couldn't display. I shared the folder here.

谢谢您的帮助!

https://drive.google.com/drive/folders/0ByNw-B9nXMcbMkxHTGt2X2xUTzQ

function doGet() {
  var html = HtmlService.createTemplateFromFile('index').evaluate()
    .setTitle('picture').setSandboxMode(HtmlService.SandboxMode.NATIVE);
  return html;
}

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
  <p> Dispaly picture </p>
    <p><img src="https://drive.google.com/drive/folders/0ByNw-B9nXMcbMkxHTGt2X2xUTzQ/200w.gif"> </p>
  </body>
</html>

推荐答案

img src=""需要您要显示的实际图像的URL,而不是包含该图像的文件夹.要获得正确的链接,您需要在其自己的窗口中打开图片,或单击共享"以这种方式获取链接.

The img src="" requires the URL of the actual image you want to display, not the folder that contains it. To get the correct link you need to open the picture in its own window or click share and get the link that way.

您图片的正确链接是:

https://drive.google.com/file/d/0ByNw- B9nXMcbSTN2S2ZiYWprdzA/视图

要在src中使用此代码,您需要将fileID添加到此格式URL的末尾:

To use this in the src you need to add the fileID to the end of this format URL:

https://drive.google.com/uc?export=download&id =

它变成:

https://drive.google.com/uc?export= download& id = 0ByNw-B9nXMcbSTN2S2ZiYWprdzA

注意:该驱动器文件必须与具有链接的任何人"共享,其他用户才能查看该文件或在G Suite之外使用.

NOTE: The drive file must be shared with 'anyone with the link' for other users to be able to view the file or for use outside of G Suite.

这篇关于如何使用&lt; img src&gt;在Google Apps脚本中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆