CellImage.getUrl() return null always

436 views
Skip to first unread message

Abdullah Yassin

unread,
Feb 16, 2023, 9:44:26 AM2/16/23
to Google Apps Script Community
CellImage.getUrl() return null always
My Sheet: 
Screen Shot 2023-02-16 at 5.41.07 PM.png

My script & ouput is nothing:
Screen Shot 2023-02-16 at 5.42.12 PM.png

cwl...@gmail.com

unread,
Feb 17, 2023, 6:47:03 AM2/17/23
to Google Apps Script Community
Images are stored at the Sheet (or tab) level, not the cell level. So you have to approach it differently. This seems to work for me:

function getCellImage() {
  const sheet = SpreadsheetApp.getActiveSheet();
  const images = sheet.getImages()
    images.forEach( (img) => {
      let anchorCell = img.getAnchorCell().getA1Notation()
      if (anchorCell === "D2") {
        console.log(img.getUrl())
        console.log(img.getAltTextTitle())
        console.log(img.getAltTextDescription())
      }
    })
}

Abdullah Yassin

unread,
Mar 1, 2023, 4:36:09 AM3/1/23
to Google Apps Script Community
sheet.getImages() is return []

Brett Grear

unread,
Mar 1, 2023, 4:52:59 AM3/1/23
to Google Apps Script Community
I could be wrong but I think you can only get the URL for inline images if they were inserted into the sheet via a url using apps script.  I don't think images inserted manually through the Sheets interface have a URL associated.
I think that sheet.getImages() only gets the images that are not cell locked.

Apologies if this is inaccurate information. I tried to do something similar a while ago and I couldn't find a way to do it.

Abdullah Yassin

unread,
Mar 1, 2023, 9:08:49 AM3/1/23
to Google Apps Script Community
Even cell within IMAGE() , doesn't work  :( 

Screen Shot 2023-03-01 at 5.05.57 PM.png
Reply all
Reply to author
Forward
0 new messages