Learn How To Insert Images From Google Drive In Apps Script

--

Hello! This is going to be a short article where I’m going to share with you the code to pull an image from Google Drive into your Google Apps Script project.

Basically, you have to be careful of how the link has to be built as I explain in this video.

This is the code in Code.gs:

function doGet(e) {
if (!e.parameter.page) {
var html = HtmlService.createTemplateFromFile(“index”).evaluate();
html.setTitle(“MY PROJECT”);
return html;
}
}
function getScriptUrl() {
var url = ScriptApp.getService().getUrl();
return url;
}
function include(fileName)
{
return HtmlService.createHtmlOutputFromFile(fileName).getContent();
}

This is how the img tag should be structured:

<img src=”https://drive.google.com/uc?export=view&id=YOUR_FILE_ID” width=”200px” height=”auto”>

I hope this short articles help you out with your programming projects.

Thanks!

--

--

Quick Programming Tips

Here you will find short tutorials to help you out with your programming projects.