Search code examples
google-apps-scriptweb-applicationsgoogle-drive-api

How to display a Google Drive image using Google Apps Scripts?


If I use the following, from Google's tutorial pages, to load an image, it works fine:

// The very first Google Doodle! app.add(app.createImage("http://www.google.com/logos/googleburn.jpg"));

but if I try to obtain a URL from own Google Docs, the image fails to load:

var image;
var url;    
var files = DocsList.getAllFiles();        
for (var i = 0; i < files.length; i++) {  
    url = files[i].getUrl();  
    app.add(app.createImage(image));  
    app.add(app.createLabel(url));  
}

The URL returned is not directly to the image but a Google Docs container of some sort:

http://docs.google.com/a/--------.com/open?id=0B5B_X4WaXYC7cExRT3Nvb0hTamc


Solution

  • yes, you can not use images stored in Google Docs. Imgae URL should be a hotlink(Direct link) to that image.

    app.createImage('YOUR_IMAGE_HOT_LINK_URL');