image - How to replace text by using Google scripts? -
i want show image google drive in google spreadsheet. have replace text: open? for: uc?export=download& in shareable link: https://drive.google.com/open?id=0bwjunx7uetdmag42egdevuvocu0
i have tried solution https://stackoverflow.com/a/42819032/2661411:
" made 2 lines script use share link of image in google drive.
- go tools > script editor.
- copy, paste following code
click on run permission
function drive_image(link){ prefix_url = "https://docs.google.com/uc?export=download&"; link.replace("open?", "uc?export=download&"); }
using script :
- copy share link of image in google drive.
- go cell
- enter formula
=image(drive_image("copied_link"))"
but didn't work me, said:
typeerror: cannot call method "replace" of undefined. (line 3, file "imgview")
any ideas? keep simple.
you need use https://docs.google.com/uc?export=download&id=<<image id>>. refer 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, can use formula =image(drive_image("https://drive.google.com/open?id=0bwjunx7uetdmag42egdevuvocu0"))
Comments
Post a Comment