Image attributes lost when updating images in emails via API | Community
Skip to main content
Level 2
February 19, 2026
Solved

Image attributes lost when updating images in emails via API

  • February 19, 2026
  • 1 reply
  • 32 views

Hi everyone,

 

I'm trying to build a semi-automated email builder using the REST API to populate our emails. We use the Email 2.0 editor and templates. Everything works great for text sections and variables, but I've hit some frustrating limitations with the Update Email Content endpoint for Image-type sections.

 

Our template's original <img> tag:
<img align="center" border="0" class="em_full_img" height="auto" src="imageurl" style="display: block; border: 0px; outline: none; width: 680px; max-width:100%; height:auto;" width="680">

 

What the API produces after updating the image:
<img alt="banner.png" style="display: block; border: 0px; outline: none; width: 680px; max-width:100%; height:auto;" width="680" src="imageurl" height="150">

 

These are the issues I’m seeing:

  • class attribute is stripped: The template has class="em_full_img" which is critical for our responsive/mobile CSS. After an API image update, this attribute is gone. I tried passing class=em_full_img as a form parameter and the API accepts it without error but it’s not actually passed into the email code, it’s just ignored.
  • height can only be set as an integer: The template uses height="auto" but the API only accepts <int32> for the height parameter. Passing height=auto returns a 1003 error. Once a numeric height is set via API, there's no way to reset it back to "auto." The style attribute can contain height:auto but the HTML attribute stays as the numeric value.
  • align="center" is stripped: Same issue. The template's align="center" is removed after an API update. Passing align=center as a form param is silently ignored.
  • border="0" is stripped: Minor but the template attribute is lost.

 

I’ve tried using the update fullContent endpoint, but this only works for non-templated emails and our emails need to stay unbroken from the template for easy editing. And I’ve thought of some workarounds like using tokens, but I really want to keep the mktoImg set up so people can easily go in and swap out an image if they need to. 

 

Questions:

  • Is there any supported way to preserve or set class and align attributes on <img> tags when updating Image sections via the API?
  • Is the fullContent update endpoint a viable workaround? Has anyone successfully used it on emails that are using templates?
  • Is there a way to set height="auto" as an HTML attribute (not just in the style)?

 

Any advice appreciated!

Best answer by SanfordWhiteman

Don’t have anything insightful. You could switch to a mktoText with the image inside. This would let a user replace the image from Design Studio, but it doesn’t lock down the attributes, so they could also break it themselves. Tough one.

1 reply

CamrynKaAuthor
Level 2
February 19, 2026

@SanfordWhiteman Your posts and replies have been life savers for me many times! Curious if you have any ideas here?

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
February 20, 2026

Don’t have anything insightful. You could switch to a mktoText with the image inside. This would let a user replace the image from Design Studio, but it doesn’t lock down the attributes, so they could also break it themselves. Tough one.

CamrynKaAuthor
Level 2
February 20, 2026

@SanfordWhiteman Yes that seems like the best option. Thanks :)