editable image

lawrence whittemore asked on April 10, 2023 16:43

is there a way to access the image path for the editable image web part (probably via a macro)? I want to use the control to populate a div's background image.

Correct Answer

Trevor Fayas answered on April 10, 2023 18:31

It's possible but a bit complicated, the Editable Image stores data in the DocumentContent field in the database.

you can use the C# syntax

CMS.DocumentEngine.DocumentContext.CurrentDocument.DocumentContent.EditableWebParts["TheEditableImageWebpartWebpartID"] to get the string content that would look like this:

<![CDATA[<image> <property name="imagepath">~/mysite/media/Images/Banners/short-banner.jpg?width=2000&amp;height=242&amp;ext=.jpg</property> </image>]]>

You can parse this in an XML document and get the image path. Lot of work but doable, and then use a custom macro to access this logic.

0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.