How can I make the ‘src’ point to images in a Google Drive folder? I’ve used HtmlService.createTemplateFromFile(‘form.html’) before, but I’m stuck on this part. Any ideas?
Hey CreativePainter33, have u tried using google drive api? it lets u fetch thumbnails directly. u could make an ajax call to get the image urls, then dynamically create ur html elements. might need some js tweaking but should work. good luck!
I’ve faced a similar challenge before. One approach that worked for me was using Google Apps Script to create a web app that serves as a bridge between your HTML form and Google Drive. Here’s a rough outline:
Write a GAS function to fetch image metadata from your Drive folder.
Create a web app that exposes this function via doGet().
In your HTML, use google.script.run to call the GAS function and get image data.
Use JavaScript to dynamically generate your image elements with the fetched data.
This method avoids direct API calls from the client-side, simplifying auth. It’s not perfect - there might be some lag if you have many images - but it’s a good starting point. You’ll need to tweak your HTML and add some JavaScript, but it should get you on the right track.
To display Google Drive thumbnails in your HTML form, you need to leverage the Google Drive API. First, set up the necessary API credentials and enable the Drive API in your Google Cloud Console, then use the files.list method to retrieve images from your folder. A high-level approach involves implementing server-side code to fetch the image metadata from Drive, passing this data to client-side JavaScript, and dynamically generating the HTML elements with correctly set src attributes. Consider using the thumbnailLink property provided by the API for each file. Remember to manage authentication properly and to implement caching to improve performance.