Reputation: 359
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.
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 :
=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.
Upvotes: 0
Views: 832
Reputation: 3355
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"))
Upvotes: 2