I've recently been evaluating using TincyMCE on my drupal site. I love the way that it works, but I'm having this problem with the base URL's for inserted images.
Basically from Firefox, when I go to edit a node with an inserted image in the body, it changes the root relative link from files/sitename/images/sample.jpg to ../../../files/netservices/sample.jpg (relative to tinyMCE?). If you then post the page, the image link is forever broken.
In IE it appears to not modify the image reference, but rather renders a broken link in TinyMCE(unless the image file link is tinymce relative.
I'm using an adjusted files location "files/sitename" rather than straight "files". I don't know if this is relavent to the problem.
TinyMCE reference a base url setting that can be passed to init to help with these kinds of troubles, but I can't find any place in the module that sets this. Should it?
Any ideas about what needs to be done to resolve this problem?
Comments
Comment #1
metzlerd CreditAttribution: metzlerd commentedI was able to fix this by doing the following:
1. Create a symbolic link in my htdocs directory for files pointing to my drupal files directory.
2. Create a symbolic link in the root of my file system (linux) pointing to /files
3. Change my default site files directory to /files (instead of "files").
This is not an optimal solution, but is a viable work-around unless you are trying to protect your images.
Dave
Comment #2
kertal CreditAttribution: kertal commentedsame problem here, i discovered that it only happens when you've clean urls enabled. then tiny_mce messes with url in general. adds "../"s . Otherwise it works ... can anybody help?
Comment #3
andre75 CreditAttribution: andre75 commentedI am having the same prob. Fortunately for me, the romote site still displays everything correctly.
I guess it is probably a better apache configuration. Which makes one wonder, if you could redirect requests to ../../files to files per .htaccess file? If someone knows how to write this into .htaccess please let me know.
Andre
www.aguntherphotography.com
www.opentravelinfo.com
Comment #4
andre75 CreditAttribution: andre75 commentedThis seems to work for me. Please use this at your own risk since I know nothing about Javascript. I simply replaced this:
With this:
in tiny_mce.js and tiny_mce_src.js. I tried a test posting and did not see any ../../ .
I'd be happy to hear some feedback. Maybe someone can come up with a cleaner implementation.
Andre
http://www.opentravelinfo.com
http://www.aguntherphotography.com
Comment #5
andre75 CreditAttribution: andre75 commentedSorry, I messed up the title of the issue.
Comment #6
gwerker CreditAttribution: gwerker commentedI've noticed this problem as well when I simply try to link to nodes. For instance, if I create a link to node/99, then click submit, it works fine. However, if I click edit to make more changes, TinyMCE then changes the link to ../99. If I submit and then click edit again, it changes it to ../../../99.
I tried altering the document_base_url param, but that didn't work for me. Has anyone else found a solution to this?
Comment #7
quicksketchThis will force all links and image paths to be absolute from you domain. That is, they will be of the format: "/files/images/whatever.jpg". Note the slash preceding the path. I think this will also affect all links, so it will probably work best with Drupal clean URLs enabled.
So, open up tinymce.module and find the line
Append to it so that we use absolute URLs instead.
More information about these settings are available at the tinyMCE website, http://tinymce.moxiecode.com/tinymce/docs/reference_configuration.html.
Comment #8
m3avrck CreditAttribution: m3avrck commentedI have talked with the main developers of TinyMCE to arrive at a fix for this and it appears the finaly version of TinyMCE 2.0 has numerous fixes for path problems. I have confirmed that the path problems I have encountered are indeed fixed with TinyMCE from CVS (soon to be version 2.0 final). Closing this issue as it appears this has been resolved.
Comment #9
Vallenwood CreditAttribution: Vallenwood commentedThe solution to this is to upgrade the tinymce files to 2.0 and then set a new flag in tinymce.module. Here's how:
The 'convert_urls' false parameter tells it to preserve whatever you type and not put crap in front of it or rewrite. This worked for me. Note that if you try to COMBINE this with some of the above-posted solutions, like also putting in a 'remove_script_host' or 'relative_urls' config parameter, it can break this solution. It did for me. Don't use them. Just add this one parameter.
Found this out by referring to tinymce manual here:
http://tinymce.moxiecode.com/tinymce/docs/faq.html#paths
Comment #10
brauchlik CreditAttribution: brauchlik commentedIt also works for me. However, I had to include the full host as well. So in tinymce.module I changed:
Comment #11
BryanSD CreditAttribution: BryanSD commentedI found in Drupal 4.7 all that was necessary to add was:
$init['convert_urls'] = "false";
Comment #12
Veggieryan CreditAttribution: Veggieryan commentedone more thing.
when dragging and dropping images from within the site, i found that they had relative url's...
to solve this I added a line
Comment #13
skilip CreditAttribution: skilip commentedIt seems like the function base_path gets it's value from the .htaccess file, doesn't it? That could explain why the paths become messed up when enabling clean url's.
I had my Drupal installation on a subdomain. So I had to hack the TinyMCE module to be able to get the subdomain's base URL path. There was no other way to get clean_urls working, besides TinyMCE, without the hack.
Comment #14
Leeteq CreditAttribution: Leeteq commentedThe following issue also mentions changes to the settings in the tinymce.module:
"TinyMCE and relative urls running with clean_urls enabled":
http://drupal.org/node/133441
Comment #15
graper CreditAttribution: graper commentedWhile I know that this is an old thread. I wanted to put in my two cents since I just found it and I think it will help others in the future.
On 4.7.8 in I was able to put into the template.php file of my theme the following lines into a tinymce_theme override function.
This allowed me to have the absolute site paths for images in newsletters to work while also allowing relative paths that IMCE puts in for images to work on other nodes.
found the code on http://drupal.org/node/133441 and just wondered if it would work in the template.php since I already have some code in there to do other things with tinymce such as to allow a bunch more html tags and remove_linebreaks to false. Hope this helps the next person until a new patch comes out.
Granville
Kirkham Systems Inc.
Comment #16
Mupsi