0

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?

Meep3D
  • 3,803
  • 4
  • 36
  • 55
  • 1
    I 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 Answers1

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
  • 1
    The 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