代码之家  ›  专栏  ›  技术社区  ›  Cooper

无法使用谷歌应用程序脚本在对话框或边栏上显示谷歌驱动器中的图像

  •  0
  • Cooper  · 技术社区  · 8 年前

    var br = '<br />';
    var images=DocumentApp.getActiveDocument().getBody().getImages();
      if(images)
      {
        s+=br + '<strong>Body Images</strong>' + br + '<strong>Number of Images: </strong> ' + images.length;
        for(var i=0;i<images.length;i++)
        {
          s+=br + '<img src="http://myWebsite.com/GmailSignature.png" width="100"/>'; //This is the only thing I can get to work
          s+=br + '<img src="https://drive.google.com/open?id=0Bx2ds1-xxxxxxxxxxxxxxxxxxxx" width="100"/>';//There's several references on StackOverFlow.com that say this should work
          s+=br + '<img src="https://drive.google.com/uc?id=0Bx2ds1-xxxxxxxxxxxxxxxxxxxx&export=download" width="100" />';
        }
      }else{s+=br + '<strong>No Images in this Body element.</strong>';}
    

    他就是我的边栏上的代码:

    enter image description here

    我网站上的链接很有效。Google Drive的链接没有。我只是把这张图片添加到我的一个谷歌网站上,并获取了这个url,效果也很好。stackoverflow的一个参考文献表明了这一点 <img src='https://drive.google.com/uc?id=" + imageId +'"' <img src='https://drive.google.com/uc?id="' + imageId + '&export=download" />' .

    1 回复  |  直到 8 年前
        1
  •  2
  •   Cooper    8 年前

    使用Google Drive-in对话框和边栏中的图像

    我认为我的问题是,我不总是使用来自可共享链接的id,可能我没有总是将其设置为可公开访问。我只是做了一个小例子,它们都很好,包括我过去在工作中遇到的一些问题。

    <!DOCTYPE html>
    <html>
      <head>
        <base target="_top">
      </head>
      <body>
        <img src="https://drive.google.com/uc?id=ShareableLinkID&export=download" width="200" />
        <img src="http://drive.google.com/uc?export=view&id=ShareableLinkID" width="200" />
        <img src="https://drive.google.com/uc?id=ShareableLinkID" width="200" />
    
      </body>
    </html>