Try our conversational search powered by Generative AI!

Programmatically adding images to RTE; No usages.

Vote:
 

Hi

Currently I am working on a one time scheduled job where images form an external DAM that are used in the RTE editor are being downloaded and referenced in the RTE from the media assets. So at first the link in the RTE is just a url in the XhtmlString to the external DAM, then the image is downloaded and placed in the media asstes. and using that content reference the url to the image is replaced by a string in the following format:

$"/EPiServer/CMS/Content/contentassets/en/{image.ContentGuid}/{image.Name},,{image.ContentLink.ID}?epieditmode=False"

This works and the image is shown in the RTE editor and on the website itself.

Now the problem:
When I do this manualy in the CMS editor and save the page. And then go to the image in the media assets I get the message "Changed made here will affect as least 2 items", one being the RTE editor. And when I click the link it shows where the image is used. (On a page as a content reference and on another page in the RTE editor).

But when I change the XhtmlString by replacing the url to the DAM with the url above I don't get the message that the image is used in the RTE editor.

How to accomplish this? What reference / link do I need to add?

Thanks in advance!

#234894
Dec 04, 2020 11:06
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.