AnsweredAssumed Answered

Tiny MCE replaces paths with relative urls

Question asked by stevewickii on Feb 8, 2008
Latest reply on Sep 5, 2014 by zhunjier
Alfresco 2.9.0B is using Tiny MCE to edit HTML content inline.  My problem is that when my A/@HREF or IMG/@SRC does not start with "http://" or "/", tiny MCE prepends the path of the editor to the URLs!

The configuration is:
theme : "advanced",
mode : "exact",
relative_urls: false,
elements : "editor",
save_callback : "saveContent",
plugins : "table",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_buttons1_add : "fontselect,fontsizeselect",
theme_advanced_buttons2_add : "separator,forecolor,backcolor",
theme_advanced_buttons3_add_before : "tablecontrols,separator",
theme_advanced_disable: "styleselect",
extended_valid_elements : "a[href|target|name],font[face|size|color|style],span[class|align|style]"

When HTML content is edited in alfresco with the TinyMCE editor, "/alfresco/faces/jsp/browse/" is prepended to img/@src and a/@href values.  I have tested and verified that this only occurs in the following situations:
    when src or href does not start with "http://" or "/".
    Example 1: "${context}/images/test.gif" gets replaced with "/alfresco/faces/jsp/browse/${context}/images/test.gif"
    Example 2: "@CONTEXT@/images/test.gif" gets replaced with "/alfresco/faces/jsp/browse/@CONTEXT@/images/test.gif"
The conversion occurs when I click the "Update" button on the Tiny MCE HTML Source editor.  I verified this by changing the @src of an img tag from "/images/text.gif" to "${context}/images/text.gif", then clicking on the Image properties in the Tiny MCE advanced editor.  The path had already been changed to "/alfresco/faces/jsp/browse/${context}/images/test.gif".

The "Insert/edit Image" dialog also exhibits this behavior.

I have multiple web sites configured to pull HTML content from one Alfresco server via the web service client API.  In order for href and src URLs to point to the right place, I must use a token within the URL to represent the destination context.  This token is replaced by the website requesting the content, with the context in which the website has been deployed, not alfresco.  The Alfresco web server is not publically accessible.

What I am trying to accomplish is this - when a piece of content is pulled from Alfresco like '<img src="${context}/images/text.gif">', then the website replaces ${context} with the webapp's context like this '<img src="/testapp1/images/text.gif">'.  Then the content is sent to the browser and the image will load properly from the public website.