Update It is now working,i dont know if google fix it or what. But if i use the image function and use the script below to find the id from the folder it works. Here is my final text if someone would need (this is not script, this is a spreadsheet funktion)
=image(TEXTJOIN("",True,"https://docs.google.com/uc?export=download&id=",index(SPLIT(Sort!P2,"/"),5)))
"Sort!p2" is where the image id is.
I have an image in a folder that I want to import into my spreadsheet (in a cell). I'm using the script from Insert image from Google Drive into Google Sheets (with some modifications).
But this only works on one of the images.
I could see that the other image is a .png and the first image was a .jpg. I tried to convert the .png into .jpg, but it still does not work.
The modified script:
function listFilesInFolder(folderName) {
//writes the headers for the spreadsheet
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Image"]);
var folderId = "1smphWTohvgOVTwGDbxrIxsFWeFd3tBNo";
var folder = DriveApp.getFolderById(folderId);
var contents = folder.getFiles();
var cnt = 0;
var file;
while (contents.hasNext()) {
var file = contents.next();
cnt++;
Logger.log(file);
Logger.log(cnt);
// writes the various chunks to the spreadsheet- just delete anything you don't want
data = [
"https://docs.google.com/uc?export=download&confirm=no_antivirus&id=" + file.getId(),
file.getDescription(),
"=image(\"https://docs.google.com/uc?export=download&id=" + file.getId() +"\")",
];
sheet.appendRow(data);
};
};