Dynamically assign images from Google Drive in Email Templates

Display image content in HTML from your Google Drive?

When you are working with Email Templates (or any other HTML content), where you wish to include an image residing on Google Drive, there are a couple of things you need to do to make them visible to the viewer.


Preparation

First of all - create a public folder to where you will copy the image before anything else. Make sure this is shared as "Anyone with the link" and with Viewer access status.

Building the image link

Next identify your file with Find File or grab it directly from upload file / save file. It is the View Link you want to work with.

We will do a couple of text replacements with this link text, so go ahead and drop two Replace Text actions in the flow, I have named them 1 and 2 to keep them apart. Then do this:

  • In the Replace Text 1

    • Insert the View Link from earlier into the first field "Text".

    • In the field "Pattern" write: https://drive.google.com/file/d/

    • In the field "Replacement Text" write: https://drive.google.com/thumbnail?id=

  • In the Replace Text 2

    • Insert the Result from Replace Text 1 into the first field "Text"

    • In the field "Pattern" write: /view?usp=drivesdk

    • Leave the field "Replacement Text" empty (See comment below for alternative).

Now you can replace the xxx content in any HTML <img src="xxx"> with the Result from Replace Text 2.

Dynamic Email Template images and tokens

With the Email Template tokens in particular, you can just write {{image_something}} in place of the actual image link in the template designer and then refer to this token in your Generate Email HTML action.

Remember to work out of a public folder, to where you copy your image before doing any of the above, or it will fail.

Bonus

Now, alternatives for Replace Text 2, in the "Replacement Text" field? You can set the size of the displayed image here if needed, using the replacement text &sz=w[width in px] or &sz=h[height in px] The pixel value is an integer of your choice (commonly 320 or similar). In the Email Template designer you do not need to worry about this as it is set from there.



Let me know if you run into any troubles, happy to help out.


//Mike