I’m feeding images from my google form that follows into my google sheet that I’m using for a page on my app. The issue I’m having is that the images are not visible unless I go into the google sheet, click on the image, and make the link viewable to anyone accessing the link. I want to know what I can do to have it automatically show the images from the link without me have to go into every image url link and update it to any can view. Any guidance would be great. Thanks!
I found an answer via DeepSeek ai… Use a Google App Script to run on change to automatically make the image links in Google Sheets visible. See below:
function updateImagePermissions() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const startRow = 2; // Assuming the first row is headers
const imageUrlColumn = 2; // Column B (change this to the column where your image URLs are stored)
const lastRow = sheet.getLastRow();
for (let i = startRow; i <= lastRow; i++) {
const imageUrl = sheet.getRange(i, imageUrlColumn).getValue();
if (imageUrl && imageUrl.startsWith(“https://drive.google.com/file/d/”)) {
const fileId = imageUrl.match(//file/d/([^/]+)//)[1];
const file = DriveApp.getFileById(fileId);
file.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.VIEW);
Logger.log(Updated permissions for file: ${file.getName()}
);
}
}
}
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.