---
title: "Inserting images"
description: "Create templates that dynamically replace placeholder images with images from data. Control their size, position, and appearance in the generated document."
canonical_url: "https://resources.docmosis.com/template-tutorials/images"
last_reviewed: 2026-06-08
---
# Inserting images
Dynamically inserting an image in to a document requires two things:
- The template controls **where**the image will appear
- The data determines **what** image is used
This article explains how to use a placeholder image in the template. The placeholder image determines the position and attributes of the image that will appear in the final document.
Please refer to this article on [how to send image data or retrieve images from a file or URL](/faq/how-to-send-image-data-or-retrieve-images-from-a-file-or-url).
### Static images
Not every image in a template will be replaced. Any image in a template that isn't marked for replacement will appear unchanged in the generated document.
### Dynamic images
Instead of using the usual \<\\> notation, Docmosis looks for placeholder images in the template.
The advantage of using a placeholder image is that the image is used to determine the size, position and attributes (eg: text wrapping) that will apply to the image in the generated document.
The placeholder image needs to be marked so that Docmosis know which images to replace.
- To mark an image using Microsoft Word \- use Bookmarks.
- To mark an image in LibreOffice Writer \- use Image\>Options\>Accessibility\>Name.
Note: The ZIP file contains an example DOCX file which has detailed instructions.
In either case the Bookmark or Name should have the format: img\_fieldName.
The "img\_" part is the instruction to Docmosis that this image should be replaced.
The "fieldName" part identifies the data that will be used to create the image.
We have provided a placeholder image in this example that will clearly stand out in a template, but any image could be used, provided it has been marked as described above.
In this example the data file contains the new image as Base64 encoded data. Please refer to this article for all of the ways image data can be specified: [How to send image data or retrieve images from a file or URL](/faq/how-to-send-image-data-or-retrieve-images-from-a-file-or-url).
# Inserting images - related json data
```json
{
"firstImage": "image:base64:[base64 omitted]"
}
```
# Inserting images - example template syntax
```docmosis
**Static Images**
If you have a static image in a template, then it will appear unchanged in the finished document.
The image above has not been marked – so Docmosis won’t change it.
**Dynamic Images**
To dynamically add an image in a document you should use a Placeholder image in the template to define where and how the image is positioned.
The image in the template will be replaced with an image from the data when a document is created using the template.
Docmosis knows that the image below should be replaced, because the image has been marked using a Microsoft Word Bookmark.
Notes:
- The bookmark syntax is different from the \<\\> syntax for text fields.
- This is because you can’t use special characters like: “\<\<” or “\>\>” or “$” in a bookmark.
- The format of the bookmark should be: img\_fieldName.
- The “img\_” part is the instruction to Docmosis that this bookmark is marking an image that should be replaced.
- The “fieldName” identifies the data that will be used to replace the image.
Bookmarking an Image:
Select the image you want to bookmark by left clicking on it.
1. Select Insert \-\> Bookmark, to open the Bookmark window.
2. Enter the name of the bookmark then click Add.
3. If you click on GoTo – the item that is bookmarked will be selected.
4. Ensure that the bookmark is of the image only and that no text has been included in the bookmark.
```