DocMergy: Insert a private image
How to insert images within DocMergy templates that have been uploaded/attached to CRM records or that have been uploaded to the HubSpot Files area where the File URL visibility is set as private
There may be cases where you want to embed private images from HubSpot within your generated document/slide/sheet and you can't/don't want to change the visibility of the file to public. In these cases you will not be able to use the standard DocMergy: Insert a Public Image approach.
In these cases, use this solution to generate a temporary link for the image so DocMergy can get the and insert the private image within your final document.
Supported Document Platforms
Current
- Microsoft Office: Word.
Planned
-
Google Drive: Docs, Slides.
-
Microsoft Office: PowerPoint.
Supported File Types
Images
- PNG (.png)
- JPEG ( .jpg, .jpeg)
PDFs
- PDFs are automatically converted into the above supported file image file types images
Process
Existing templates:
-
Add the reader_file token to your template.
For Word:
-
Update the template file location referenced from the DocMergy generate file action.
New templates:
- Create/update your existing template in Microsoft Office or Google Drive (note above current support).
-
Add the reader_file token to your template.
- If Microsoft Office:
- Add your template to a location that can be accessed by DocMergy.
- Create a new Workflow in HubSpot.
- Add the relevant DocMergy action to generate your file.
- Complete the required action fields.
Tokens
Base token
-
Copy and paste the following token into your template.
-
Replace the file_property reference with the internal name of the Object property.
render_file({{ object.file_property }})
If the property contains one or more files, the files will be inserted into the document one after another with a new line in-between.
Control the inserted image size
You can optionally control the size of the inserted images using pixel values.
-
Copy and paste the following token into your template.
-
Replace the file_property reference with the internal name of the Object property.
- Replace the maxWidth and/or maxHeight references with the final desired pixel width/height of your inserted image.
render_file({{ object.file_property }}, maxWidth)
render_file({{ object.file_property }}, maxWidth, maxHeight)
Example usage:
| Example | Result |
| render_file({{ object.file_property }} | Default image size |
| render_file({{ object.file_property }}, 200)% {endraw %} |
Image max width = 200px. |
| {% raw %}render_file({% raw %}{{ object.file_property }}, 400, 200){endraw %} | Image max width = 200px. Image max height = 200px. This may stretch the image if the aspect ratio of the specified height and width is different to the source image. |
- If you aspect ratio is different in the specified height:width within your token to the source image, the final inserted images will be stretched. To avoid this:
- Recommended: Only enter a height or width.
- If you must enter a height or width:
- Try to ensure that your source image aspect ratio will be standardized or close to a standardized aspect ratio - hint: use the HubSpot Workflow Media Manager Actions app to resize and crop images to standard sizes.
- Calculate the source image standard ratio, e.g. width/height, then specify your inserted images height and calculate your inserted images width.
- e.g.
source width: 1,000px / source height: 500px = 2
inserted width: 200px / source aspect ratio: 2 = inserted height: 100px
- e.g.
Exclusions / Not-supported
-
This feature currently dose not support looping or repeating content - if you have an existing public image file, in the correct format and size you can use the standard insert image token approach.