MODx: TinyMCE relative URL hack
MODx version: Revolution 2.0.0-beta-5 rev6224
TinyMCE: 3.2.7.0
There is a current bug that I have seen a lot of activity about in the forums regarding TinyMCE and relative paths, specifically when inserting images. Essentially, even though the path inside the image selector in TinyMCE says “/assets/images/xyz.jpg”, it changes it to “../../assets/images/xyz.jpg” upon inserting.
While this isn’t a very graceful fix, it is a noted bug, so hopefully this gets everyone through to the official patch:
- Navigate to /core/components/tinymce/tinymce.class.php
- Scroll down to line 134, and you will find:
- This is looking for a system configuration variable called “path_options”. Who would think to change that, and what to change it to? Rather than making a square peg fit in a round hole, I preferred to just comment that whole statement out and replace it with:
- TinyMCE will now stop converting /assets to ../../assets or whatever other craziness it was doing. A prickly but easy workaround until it is officially fixed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | /* Set relative URL options */ switch ($this->config['path_options']) { case 'rootrelative': $this->config['relative_urls'] = false; $this->config['remove_script_host'] = true; break; case 'docrelative': $this->config['relative_urls'] = true; $this->config['document_base_url'] = $this->config['assets_url']; $this->config['remove_script_host'] = true; break; case 'fullpathurl': $this->config['relative_urls'] = false; $this->config['remove_script_host'] = false; break; } |
1 | $this->config['convert_urls'] = false; |
Enjoy,
John




I am John Roa, a web entrepreneur from Chicago. Welcome to my blog!