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)


"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();
var folderId = "1smphWTohvgOVTwGDbxrIxsFWeFd3tBNo";

var folder = DriveApp.getFolderById(folderId);
var contents = folder.getFiles();

var cnt = 0;
var file;

while (contents.hasNext()) {
    var file = contents.next();

    // 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(),
            "=image(\"https://docs.google.com/uc?export=download&id=" + file.getId() +"\")",


The spreadsheet

Google drive folder Scripts

  • Welcome. You said "but it still does not work". Would you elaborate on what you mean by this? Does the code fail, does it ignore images? What debugging have you done to identify whether each of the rows of the code are operating as expected?
    – Tedinoz
    Commented Oct 12, 2019 at 2:32
  • For starters, you have not edited data completely. It should be data = ["=image(\"https://docs.google.com/uc?export=download&id=" + file.getId() +"\")"];
    – Tedinoz
    Commented Oct 12, 2019 at 4:13
  • When I run the code, I can list all the files but NONE of the images will display. Have you read [ ](webapps.stackexchange.com/q/86081/196152) &/or Cannot link to an image from Blogger to Google Drive?
    – Tedinoz
    Commented Oct 12, 2019 at 4:46
  • @Tedinoz 1. "bit it still does not work" - what i mean is that the pitures in my folder is not showing in my spreadsheet, only one.(as u can see in picture one and two in this post) 2. I tryd this and getting the same resultat but only diffrence is that i only getting one cell insed 3.Yes i have read those and it always end upp i neet to fix a shareable link for each and every image Commented Oct 12, 2019 at 15:19
  • I wonder what would happen if you (temporarily) removed that first image from your folder (leaving only 4 images)? Would it display the first image only? Having said that, I regret that I have exceeded my competence on this subject. It does seem that Google is going to stop publishing Drive images to sheets; it's not clear whether we are witnessing their oh,s0,subtle way of doing that. Of course the other option is to the use API, but I am not sure that this is any more likely to work.
    – Tedinoz
    Commented Oct 12, 2019 at 23:56


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.