getRenderedContent img src not relative

I have a document that is used to render contents of other documents but getRenderedContent is rendering image sources relative to the page with the velocity script.

How do I make getRenderedContent render the correct absolute paths for images.

Option 1: You could use absolute image references instead of relative ones
Option 2: Use the context macro to make them be resolved relative to some other place. See http://extensions.xwiki.org/xwiki/bin/view/Extension/Context%20Macro

  1. I am unable to use absolute image references as the content is entered by other users via copy and paste.

  2. I have tried numerous variations of the context macro an none of them have had any effect on the image paths. getRenderedContent always renders them relatave to the rendering page - not the child:

    #foreach ($name in $query.execute())
    #set ($childDocument = $xwiki.getDocument($name))

    {{context document="$name"}}

    $childDocument.getRenderedContent()

    {{html xwiki=“true”}}

    $childDocument.getPlainTitle()

    $childDocument.getRenderedContent()
    {{/html}}

    {{/context}}

    #end

    I managed to get it working using the include macro:

      #foreach ($name in $query.execute())
        #set ($childDocument = $xwiki.getDocument($name))
    
    {{html xwiki="true"}}
    <div class="operation">
      <h2>$childDocument.getPlainTitle()</h2>
      <div class="operation-content">
    {{/html}}
    
    {{context document="$name"}}
    {{include reference="$name"/}}
    {{/context}}
    
    {{html xwiki="true"}}
      </div>
    <div>
    {{/html}}
    
      #end

Unfortunatly this is no good to me as the {{html}} macro appears to sanitise the TML by closing the div tags.

By default yes but you can use {{html clean="false"}} to tell it to not try to be clever.