0

I have a Google Sheet doc that has column called Imgs which contains a cell with multiple URLs that links to multiple images:

enter image description here

So, I would like to do the following with an Apps Script:

  1. Split the URLs by eliminating the comma delimitator

  2. Find a way to create an array with each URL

  3. Pick URL by URL from the array and then attach each one to the Google Doc as images, leaving something like this

Here's the link to the Google Sheet as an example: link

Any help would be appreciated!

0

First, you'll want to prepare the cells in the results range to display the images. In the case of your post example and sample spreadsheet, right-click on the "2" to the left of Row 2, choose "Resize row" from the flyout menu, click the radio button by "Specify row height" and enter 58 for the value.

Once that is done, place the following formula in D2:

=ArrayFormula(HYPERLINK(SPLIT(REGEXREPLACE(A2,"(,).","$1"),",",0),IMAGE(SPLIT(REGEXREPLACE(A2,"(,).","$1"),",",0))))

This formula should produce the images for each of the five links while also retaining the hyperlink if you hover of each of the images.

If you will be trying to do this for multiple rows in A2:A, then do the following:

  1. Regular-click the "2" to select Row 2, scroll to the bottom of the sheet (or as far as you will want images), hold down SHIFT and click the bottom-most row number. This will select all of the rows in between.

  2. Right-click on the bottom-most row number and repeat the process described above for resizing the rows to 58.

  3. Insert the following version of the above formula in D2:

=ArrayFormula(IF(A2:A="",,HYPERLINK(SPLIT(REGEXREPLACE(A2:A,"(,).","$1"),",",0),IMAGE(SPLIT(REGEXREPLACE(A2:A,"(,).","$1"),",",0)))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.