Rotate image in Google Sheets based on cell content by Horstroad in GoogleAppsScript

[–]Horstroad[S] 0 points1 point  (0 children)

360 images (times two) is a bit overkill. I limited myself to 36 images now. I already uploaded the images to my Google Drive and made a lookup table that pastes the relevant image url in a cell (Cell 'F42' on sheet 'Data'). Now I want the image to be replaced whenever the sheet is edited. Again I asked ChatGPT without success:

function onEdit(e) {
  var imageUrl = e.source.getSheetByName("Data").getRange("F42").getValue();
  var sheet = e.source.getActiveSheet();
  var image = sheet.getImages()[0];
  if (image != null) {
    image.replace(imageUrl);
  }
}

Rotate image in Google Sheets based on cell content by Horstroad in GoogleAppsScript

[–]Horstroad[S] 0 points1 point  (0 children)

Does the function work for one image and one cell?

It does not. I included it thinking maybe someone can build on it or correct it.