Making Drupal's TinyMCE module produce domain absolute URLs
By default Drupal's excellent TinyMCE module will convert domain aboslute URLs (e.g. http://www.stress-free.co.nz/files/u63/drupal_logo.png) into plain old absolute URLs (e.g. /files/u63/drupal_logo.png). Generally this is not a problem so long as you do not want to use an external web service such as FeedBurner for your RSS feeds. Unfortunately FeedBurner does not handle plain old absolute URLs very well. This is because the domain name for your FeedBurner enabled RSS feed is feeds.feedburner.com and any absolute (or relative) links in your post try resolving to this domain name rather than the original website.
In a perfect world FeedBurner would parse incoming RSS feeds and replace absolute/relative URLs with domain aboslute URLs to ensure everything works (or maybe it can and I haven't figured out how to do this). Fixing this problem in Drupal when you are using the TinyMCE editor is a little tricky because TinyMCE tries to be helpful by replacing your domain absolute URLs. To get around this we have to tell TinyMCE to leave these URLs alone and convert any new absolute or relative URLs into their domain absolute equivalents.
To achieve this edit the modules/tinymce/tinymce.module file in your Drupal site and change the following lines (line numbers relate to 5.x-1.x-dev release of the TinyMCE module):
Line 494 change:
$host = $base_url;
to your site's domain name:
$host = "http://www.yoursite.com/";
Between lines 505-506
$init['relative_urls'] = 'false';
$init['document_base_url'] = "$host";
add the following extra parameter:
$init['relative_urls'] = 'false';
$init['remove_script_host'] = 'false';
$init['document_base_url'] = "$host";
These settings are taken from the TinyMCE FAQ on the subject. Once you have made these changes you should find TinyMCE behaves itself much better when it comes to using FeedBurner.
Alternatively, use the Pathologic Input Filter
Thanks, looks good
Thanks for the pointer, it looks pretty tidy.
I did this in 4.7.8 and it worked
While 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, I was able to put into the template.php file of my theme the following lines into a tinymce_theme override function.
function phptemplate_tinymce_theme($init, $textarea_name, $theme_name, $is_running) {
$init['relative_urls']='true';
$init['document_base_urls']=$_SERVER['HTTP_REFERER'];
$init['convert_urls']='false';
}
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 setting remove_linebreaks to false. Hope this helps the next person until a new patch comes out.
Granville
http://www.kirkhamsystems.com
Nice but untested on Drupal 5/6
The above code looks useful but hasn't been tested on Drupal 5/6. If you or anyone tries it on these versions let me know.
Fixed it!
Okay, after some googling - this wasn't hard at all. I found this page (http://drupal.org/node/32320) and simply adding
$init['convert_urls'] = "false";
did the trick for me. Thanks for putting me on the right track with your post.
John
Any ideas how this could be fixed in 4.7?
Hi,
Unfortunately, I'm not at Drupal 5.X yet. Any ideas on how this would work for Drupal 4.7? I am having this exact problem, links in feedburners RSS and RSS2Email service break.
Thanks!
John