I've written a plugin that allows users to add images to TinyMCE, which works. The problem is that the saved html when displayed may vary depth in the URL - e.g. mysite.com/path/path/path/page.htm which would render any image links broken as the path depth changes. I don't want to use absolute paths, is there a good approach to fixing this?
Asked
Active
Viewed 1,423 times
0
-
1I think this post will help http://stackoverflow.com/questions/92720/jquery-javascript-to-replace-broken-images – Terrance May 27 '11 at 13:44
-
Interesting, but I think i'd like to try and do it server-side as relying on javascript to fix things seems a bit wrong. – Meep3D May 27 '11 at 13:47
-
So what server side language are you using? – Terrance May 27 '11 at 13:50
-
PHP. I can think of a few approaches but they seem pretty hacky and am just wondering if TinyMCE has something for this problem. – Meep3D May 27 '11 at 14:12
1 Answers
2
If you don't want to use absolute paths you can configure tinymce using the init and the following
relative_urls : true,
document_base_url : "http://www.mysite.com/path_x/",
This will convert all URLs within the same domain to relative URLs. The URLs will be relative from the document_base_url. You may define the base URL as short as needed.
Here is a link to the possible tinymce settings concerning paths.

Thariama
- 50,002
- 13
- 138
- 166
-
1The problem is TinyMCE doesn't know the base path and the same entry can be used (theoretically) at multiple different path indentation levels. – Meep3D May 27 '11 at 14:11