0

I want to show an image from Google Drive in a Google Spreadsheet. I have to replace the text: open? for: uc?export=download& in the Shareable link: https://drive.google.com/open?id=0BwJUnx7uETDmaG42eGdEVUVocU0

I have tried this solution https://stackoverflow.com/a/42819032/2661411:

" I made a two lines script to use the share link of an image in Google Drive.

  1. Go to Tools > Script editor.
  2. Copy, paste the following code
  3. Click on run for permission

    function DRIVE_IMAGE(link){ prefix_url = "https://docs.google.com/uc?export=download&"; link.replace("open?", "uc?export=download&"); }

Using the script :

  1. Copy the share link of your image in Google Drive.
  2. Go to a cell
  3. Enter the formula =IMAGE(DRIVE_IMAGE("COPIED_LINK")) "

But didn't work for me, it said:

TypeError: Cannot call method "replace" of undefined. (line 3, file "ImgView")

Any ideas? I would like it to keep it simple.

1 Answer 1

2

You need to use https://docs.google.com/uc?export=download&id=<<IMAGE ID>>. Refer the below formula.

=image("https://docs.google.com/uc?export=download&id=0BwJUnx7uETDmaG42eGdEVUVocU0")

Script

/**
 * @customfunction
 */
function DRIVE_IMAGE(link){
   var newLink = link.replace("https://drive.google.com/open?", "https://docs.google.com/uc?export=download&");
   return newLink;
}

Now, you can use the formula =IMAGE(DRIVE_IMAGE("https://drive.google.com/open?id=0BwJUnx7uETDmaG42eGdEVUVocU0"))

Sign up to request clarification or add additional context in comments.

3 Comments

That is what I'm trying to do... but how? (I need a script)
@isk27 I have added the script
Is there any way to make a range selection? for example, I got a column with all the links to the images in the Drive and in the next column the formula that gets the correct link from the other column in the same row?

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.