Search the body of a Google Doc for a specific string/pattern and insert an image in place of it.
In this example the code is designed to sit behind the Google Doc so it is bound to it. There are 4 pieces of information to complete in order to setup the script:
- searchText – this is the unique string/pattern in the Doc that you want to replace with an image e.g. “<<keyword>>“
- imageURL – this is the direct link to the image in Google Drive that you wish to use in the Doc.
- size – a numerical value representing the number of pixels for the image’s width/height.
- hyperlinkURL – if you want the image to be clickable then provide a link for it.
Source: The Gift of Script: Replace text in a Google Doc with an image
I use Google Apps Script to support staff and students in my job. I enjoy dabbling with creating tools to help with automation and I freely share my learning experiences on my blog, where I also have a number of useful Google Add-ons: www.pbainbridge.co.uk