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.

  1. go tools > script editor.
  2. copy, paste following code
  3. 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 :

  1. copy share link of image in google drive.
  2. go cell
  3. 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

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -