Edit in GitHubLog an issue

Use Images

Import Images into the page

Add-ons are hosted in an iframe within the Adobe Express UI, and can load images as <img> elements like any other web application. But in order to add images into an Adobe Express document, you need to use the addImage() method of the addOnUISdk.app.document object.

It expects a Blob object as the first argument, and an optional MediaAttribute object with the image's title and author.

Example

Copied to your clipboard
// ui/index.js
import addOnUISdk from "https://express.adobe.com/static/add-on-sdk/sdk.js";
addOnUISdk.ready.then(async () => {
try {
const imageUrl = "https://placehold.co/600x400.png";
const image = await fetch(imageUrl);
const imageBlob = await image.blob();
await addOnUISdk.app.document.addImage(
imageBlob, // 👈 Blob object
{
title: "Placeholder image", // 👈 Optional MediaAttributes
author: "Adobe Developer",
}
);
} catch (e) {
console.error("Failed to add the image", e);
}
});

You can use fetch() also to get images that are local to the add-on; in this case, paths should be relative to the add-on's root.

Copied to your clipboard
// ui/index.js
import addOnUISdk from "https://express.adobe.com/static/add-on-sdk/sdk.js";
addOnUISdk.ready.then(async () => {
try {
const imageUrl = "./600x400.png"; // 👈 Local image
const image = await fetch(imageUrl);
// ... same as before

Import Animated images

Importing a GIF via addImage() won't work as expected, as the method converts the animation into a static image before adding it to the document. You should use the addAnimatedImage() method instead.

Example

Copied to your clipboard
// ui/index.js
import addOnUISdk from "https://express.adobe.com/static/add-on-sdk/sdk.js";
addOnUISdk.ready.then(async () => {
try {
const gifImageUrl = "https://path/to/a/file.gif"; // 👈 a GIF image
const gifImage = await fetch(gifImageUrl);
const gifImageBlob = await gifImage.blob();
await addOnUISdk.app.document.addAnimatedImage(
// 👈
gifImageBlob, // 👈 Blob object
{
/* ... */
} // 👈 Optional MediaAttributes
);
} catch (e) {
console.error("Failed to add the image", e);
}
});

Replace Media

The replaceMedia() method can be used to replace an existing media with a new one. It accepts a single argument of type BitmapImage.

Example

Because the Document Sandbox doesn't have access to the fetch() function, in the following example the Bitmap data is fetched on the iframe side, and passed to the Document Sandbox to be replaced using the Communication API.

You can copy and paste the following code into a Code Playground session to try it out.

Copied to your clipboard
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Get Started</title>
</head>
<body>
<div class="container">
<button id="replace-media-btn" disabled>Replace Media</button>
</div>
</body>
</html>

Media Node structure

It may be useful to know how Adobe Express represents media nodes in a document, using three Classes:

  1. MediaContainerNode, the main container

The parent node that displays media within a crop mask. It holds two children:

  • maskShape: a FillableNode defining the visible bounds.
  • mediaRectangle: the actual media (image or video). It also provides replaceMedia() to swap content.
  1. MediaRectangleNode, the abstract base

An abstract base for uncropped, full-frame rectangular media. It can’t be instantiated directly, but defines core properties (width, height, and media data) and shared behavior for positioning, rotation, and sizing.

  1. ImageRectangleNode, the concrete class

A subclass of MediaRectangleNode for bitmap images. Created through Editor.createImageContainer(), it inherits all sizing and positioning features while representing the specific image content.

Copied to your clipboard
MediaContainerNode
├── maskShape > FillableNode, defines visible area
└── mediaRectangle > MediaRectangleNode
└── ImageRectangleNode > for images
└── UnknownMediaRectangleNode > for other media types

FAQs

Q: How do I add images to a document?

A: Call addOnUISdk.app.document.addImage(blob, attributes) with image blob and optional MediaAttribute.

Q: What parameters does addImage require?

A: A Blob object is required, MediaAttribute with title and author is optional.

Q: How do I get an image as a blob?

A: Use fetch(imageUrl).then(r => r.blob()) to convert images to blob format.

Q: Can I use local image files?

A: Yes, use relative paths from add-on root with fetch() to load local images.

Q: How do I add animated GIFs?

A: Use addOnUISdk.app.document.addAnimatedImage(blob, attributes) instead of addImage().

Q: Why doesn't addImage work with GIFs?

A: addImage() converts animations to static images; use addAnimatedImage() to preserve animation.

Q: What image formats are supported?

A: AI, GIF, JPEG, JPG, PNG, PSD, PSDT, and WEBP. 8000px or 80MB.

Q: Are there GIF size limitations?

A: Yes, refer to the FAQ section for specific GIF size and weight limitations.

Q: How do I replace media in an existing MediaContainerNode?

A: Use the replaceMedia() method on a MediaContainerNode with a BitmapImage object created via Editor.loadBitmapImage().

Q: Can I replace any media type with replaceMedia()?

A: Currently, replaceMedia() only accepts BitmapImage objects. The original media can be any type, but replacement must be a static image.

  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2025 Adobe. All rights reserved.