如何防止tinyMCE修改rails中的图像URL
我在 Rails 中遇到了 tinyMCE 和图像 URL 的问题。我使用以下 URL 插入了图像:
http://mydomain.com/fold1/fold2/fold3/2010/name.png
并且图像已正确插入。但是,当我右键单击图像并选择插入/编辑图像时,会出现以下内容(而不是我粘贴的 URL):
../../../fold2/fold3/2010/name.png
由于我在更多页面上使用此图像,因此此相对 URL 不会为我工作。我想设置tinyMCE根本不修改URL。 URL 应该和我写的完全一样!
在我做了一些挖掘之后,我相信我应该在 tinyMCE.init 中设置 convert_urls : false 。我说得对吗?但我无法设置这个。
我使用 grep -r "tinyMCE.init" * 在我的 rails 项目中查找 tinyMCE.init 函数,并发现了一个对 init 函数的调用在 public/javascripts/tiny_mce/plugins/fullscreen/fullscreen.htm 文件中。 init 函数的调用如下所示:
tinyMCE.init(settings)
调用上方有这段代码,它设置设置:
// Set options
delete settings.id;
settings['mode'] = 'exact';
settings['elements'] = 'fullscreenarea';
settings['add_unload_trigger'] = false;
settings['ask'] = false;
// settings['document_base_url'] = window.opener.tinyMCE.activeEditor.documentBaseURI.getURI();
settings['fullscreen_is_enabled'] = true;
settings['fullscreen_editor_id'] = oeID;
settings['theme_advanced_resizing'] = false;
settings['strict_loading_mode'] = true;
//I ADDED THIS TWO LINES
settings['convert_urls'] = false;
settings['relative_urls'] = false;
如您所见,我用“document_base_url”注释掉了该行并添加了最后两行。但这行不通。当我插入 URL 时,它们仍在修改。谁能帮我解决这个问题吗?
I have a problem with tinyMCE and Image URLs in rails. I inserted the image with this URL:
http://mydomain.com/fold1/fold2/fold3/2010/name.png
and the image is properly inserted. But when I right-click on the image and select insert/edit image, there is this (instead of the URL I pasted):
../../../fold2/fold3/2010/name.png
Since I use this image on more pages, this relative URLs doesn't work for me. I want to set that tinyMCE doesn't modify the URL at all. The URL should be exactly the same, as I write it!
After i did some digging, I believe I should set convert_urls : false inside tinyMCE.init. Am I right? But I am not able to set this.
I looked for tinyMCE.init function inside my rails project with grep -r "tinyMCE.init" * and I found one call of init function inside public/javascripts/tiny_mce/plugins/fullscreen/fullscreen.htm file. The call of init function looks like:
tinyMCE.init(settings)
above the call there is this code, which set the settings:
// Set options
delete settings.id;
settings['mode'] = 'exact';
settings['elements'] = 'fullscreenarea';
settings['add_unload_trigger'] = false;
settings['ask'] = false;
// settings['document_base_url'] = window.opener.tinyMCE.activeEditor.documentBaseURI.getURI();
settings['fullscreen_is_enabled'] = true;
settings['fullscreen_editor_id'] = oeID;
settings['theme_advanced_resizing'] = false;
settings['strict_loading_mode'] = true;
//I ADDED THIS TWO LINES
settings['convert_urls'] = false;
settings['relative_urls'] = false;
As you can see I commented out the line with 'document_base_url' and added the last two lines. But this doesn't work. The URLs are stil modifying when I insert them. Can anyone help me with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试添加这个:
Try adding this:
此页面可能会帮助您决定选择什么网址设置: http://www.tinymce.com/尝试/url_conversion.php
This page might help you to decide what url setting to choose: http://www.tinymce.com/tryit/url_conversion.php