Image as dynamic content in compatibility mode | Community
Skip to main content
Level 2
February 27, 2023
Solved

Image as dynamic content in compatibility mode

  • February 27, 2023
  • 1 reply
  • 779 views

How can I put an image as dynamic content if I import an HTML and i am in compatibility mode.

I don't see the option to create dynamic content

Cannot use structure, content, and fragment components

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by akshaaga

@sebastian_quevedo ,

If you're working with HTML in compatibility mode and cannot use structure, content, and fragment components, you can still add dynamic content to your page using JavaScript.

One way to add an image dynamically is to create an IMG element in JavaScript and append it to the DOM.

Something like this -

var img = document.createElement("img");
img.src="path/to/image.jpg";
// Append the image element to a container in the DOM
var container = document.getElementById("image-container");
container.appendChild(img);

Through this, you create a new "image" element and set its src attribute to the image path you want to display.
Then you find a container element in the DOM (using getElementById or some other method) and append the image element to it.

1 reply

akshaaga
Adobe Employee
akshaagaAdobe EmployeeAccepted solution
Adobe Employee
March 2, 2023

@sebastian_quevedo ,

If you're working with HTML in compatibility mode and cannot use structure, content, and fragment components, you can still add dynamic content to your page using JavaScript.

One way to add an image dynamically is to create an IMG element in JavaScript and append it to the DOM.

Something like this -

var img = document.createElement("img");
img.src="path/to/image.jpg";
// Append the image element to a container in the DOM
var container = document.getElementById("image-container");
container.appendChild(img);

Through this, you create a new "image" element and set its src attribute to the image path you want to display.
Then you find a container element in the DOM (using getElementById or some other method) and append the image element to it.