Skip to main content

Dynamic Images

Serve personalized images to each recipient by using merge tags inside image URLs. The editor keeps a sample image for design preview, and the dynamic URL replaces it at send time.

import { useRef } from "react";
import {
PexelizeEditor,
PexelizeEditorRef,
} from "@pexelize/react-email-editor";

function DynamicImageEditor() {
const editorRef = useRef<PexelizeEditorRef>(null);

return (
<PexelizeEditor
ref={editorRef}
editorKey="px_your_key"
editorMode="email"
options={{
features: {
dynamicImage: true,
},
}}
/>
);
}

When enabled, every Image tool in the editor shows a Dynamic Image section at the top of its content properties panel.

How it works

Dynamic images use two separate URLs stored in the design:

FieldPurposeExample
Image URL (src.url)Sample image shown in the editor and previewhttps://cdn.example.com/birthday-sample.png
Dynamic URL (dynamicUrl)Merge-tag URL used in the exported HTMLhttps://img.nifty.com/card?name={{first_name}}

The editor always displays the sample image so you can design the layout accurately. When you export the HTML, the dynamic URL replaces the sample image in the <img src> attribute. Your sending platform (Mailchimp, Klaviyo, SendGrid, etc.) then resolves the merge tags for each recipient at delivery time.

Design time:  <img src="https://cdn.example.com/birthday-sample.png" />
Export HTML: <img src="https://img.nifty.com/card?name={{first_name}}" />
Sent to John: <img src="https://img.nifty.com/card?name=John" />
Sent to Katie: <img src="https://img.nifty.com/card?name=Katie" />

End-user workflow

  1. Drag an Image tool onto the canvas.
  2. Upload or select a sample image that represents the dynamic content (e.g., a birthday card with a placeholder name).
  3. Toggle Dynamic Image ON in the content properties.
  4. Enter the Dynamic URL containing merge tags (e.g., https://img.nifty.com/card?name={{first_name}}).
  5. Optionally set an Image Title for the title attribute.

The sample image remains visible in the editor canvas and preview. The dynamic URL is only used in the exported HTML.

Upload a sample image

For the best design experience, upload a representative sample image before enabling the dynamic URL. This lets you see realistic dimensions and layout in the editor. The default placeholder works but does not show the actual content dimensions.

Example dynamic URLs

Personalized birthday card:

https://img.niftyimages.com/birthday?name={{first_name}}

Countdown timer:

https://img.countdownmail.com/timer.png?end={{event_date}}

Product recommendation:

https://cdn.example.com/recommend?cust_id={{customer_id}}&offer={{offer_id}}

Abandoned cart product image (pure merge tag):

{{item.image}}
Dynamic image services

Services like NiftyImages and CountdownMail generate personalized images on the fly from URL parameters. Combine them with merge tags for powerful personalization.

Design JSON structure

When dynamic image is enabled, the image content stores these additional fields:

{
"type": "image",
"values": {
"src": {
"url": "https://cdn.example.com/birthday-sample.png",
"width": 600,
"height": 300
},
"dynamicImage": true,
"dynamicUrl": "https://img.nifty.com/card?name={{first_name}}",
"imageTitle": "Personalized Birthday Card",
"altText": "Birthday card",
"size": { "autoWidth": true, "width": "100%" },
"textAlign": "center"
}
}
FieldTypeDescription
dynamicImagebooleanWhether dynamic image mode is enabled
dynamicUrlstringThe merge-tag URL used in exported HTML
imageTitlestringValue for the title attribute when dynamic mode is on

Exported HTML

When dynamicImage is true and dynamicUrl is set, the exported HTML uses the dynamic URL as the image source:

<img
src="https://img.nifty.com/card?name={{first_name}}"
alt="Birthday card"
title="Personalized Birthday Card"
width="580"
height="auto"
style="display: block; height: auto; border: 0; width: 100%;"
/>

When dynamicImage is false or dynamicUrl is empty, the exported HTML uses the regular src.url:

<img
src="https://cdn.example.com/birthday-sample.png"
alt="Birthday card"
title="Birthday card"
width="580"
height="auto"
style="display: block; height: auto; border: 0; width: 100%;"
/>
Merge tags are not resolved by the editor

The editor exports merge tags as-is (e.g., {{first_name}}). Your email service provider is responsible for replacing them with actual recipient data at send time. The editor preview always shows the sample image.

Disabling the feature

Set dynamicImage to false in the features config to hide the dynamic image toggle from the image tool, even if the plan allows it:

options: {
features: {
dynamicImage: false,
},
}

When omitted or set to true, the feature follows the plan-level permission (core.dynamicImage).

Configuration reference

PropertyTypeDefaultDescription
features.dynamicImagebooleanundefinedEnable or disable the dynamic image toggle. undefined or true defers to the plan. false explicitly disables.

Next steps