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









