TinyMCE/MCImageManager路径问题
我在tinyMCE 中的路径上遇到了各种奇怪的问题。 我不确定它是否与 MCImageMana 有关,我将尝试总结我的设置:
我有一个 .NET 网站。 目前应用程序根目录位于 http://localhost/APP/
tiny_mce 托管在 ~/tiny_mce(图像管理器)中插件当然在 ~/tiny_mce/plugins/imagemanager
~/uploads 是我想要上传/管理图像的地方
~/tiny_mce/plugins/imagemanager/web.config 包含此键:
它还包含
考虑到应用程序根目录不在主机名根目录(说真的,我不应该对此进行硬编码......但这是另一个问题)
到目前为止一切都很好 - 当我从tinyMCE中的图像对话框浏览时,我得到图像浏览器并浏览正确的文件夹
当我选择图像时,奇怪的事情就开始了。 以下是“插入/编辑图像”表单上“图像 URL”框中的内容:
../
APPot/upload /Image.JPG APPot? 我勒个去? 不应该只是“upload/Image.JPG”吗?
这是
tinyMCE.init({
//.....
relative_urls: true,
remove_script_host: true,
document_base_url: 'http://localhost/APP/'
});
,而且
mcImageManager.init({
relative_urls: true,
remove_script_host: true,
document_base_url: 'http://localhost/APP/'
});
我不知道第二个是否有必要,甚至不知道
“ot”来自哪里? 我认为它的存在是它无法弄清楚如何使用 document_base_url 的原因。
如果我将 url 前缀重置为原始设置:
,我最终会得到:
../upload/DSCF0546.JPG
实际上看起来更接近一些。 那里没有塞满“ot”,但它是一个目录。
有人知道发生了什么事吗?
I am having all sorts of weird issues with paths in the tinyMCE. I'm not sure if it has to do with the MCImageManaI'll try to summarize my setup:
I've got a .NET website. For now the application root is at http://localhost/APP/
tiny_mce is hosted in ~/tiny_mce, the imagemanager plugin is of course in ~/tiny_mce/plugins/imagemanager
~/uploads is where I want the images to be uploaded/managed
~/tiny_mce/plugins/imagemanager/web.config contains this key: <add key="filesystem.rootpath" value="../../../upload" />
It also contains <add key="preview.urlprefix" value="{proto}://{host}/APP/" />
to account for the app root being not at the hostname root (seriously, I shouldn't have to hardcode that....but that's another issue)
So far so good -- when I browse from the image dialog in tinyMCE, I get the image browser and it browses the correct folder
The weirdness starts when I select an image. Here's what gets put in the "Image URL" box on the "Insert/edit image" form:
../APPot/upload/Image.JPG
APPot? What the hell? Shouldn't it just be "upload/Image.JPG"?
This was with
tinyMCE.init({
//.....
relative_urls: true,
remove_script_host: true,
document_base_url: 'http://localhost/APP/'
});
and also
mcImageManager.init({
relative_urls: true,
remove_script_host: true,
document_base_url: 'http://localhost/APP/'
});
I can't tell if that second one is necessary, or even doing anything
where is "ot" coming from? I assume its existance is why it can't figure out how to use the document_base_url.
If I reset the url prefix to the original setting: <add key="preview.urlprefix" value="{proto}://{host}/" />
, i end up with:
../upload/DSCF0546.JPG
which actually seems a little closer. No "ot" crammed in there, but it's a directory off.
Anybody know what's going on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
TL;DR
示例配置
www.example.com
具有的 DocumentRoot
/var/www-data/
/var/www/uploads/images/var/www
从虚拟主机static.example.com
提供图像相应设置
preview.wwwroot
设置为/var/www
filesystem.rootpath
设置为/var/www/uploads/images
code>preview.urlprefix
设置为http://static.example.com
(或//static.example.com
)说明
扩展 当wild'ds'出现时编码!
问题在于
Moxiecode_ManagerEngine::convertPathToURI
使用一段代码$uri = substr($abs_path, strlen($root));
其中$abs_path< /code> 是“服务器”路径 (
/var/www/uploads/images/image.png
),$root
是$root = $this- >getSiteRoot();
。 默认情况下,MCIE 会尝试“猜测”siteroot url(它猜测错误的/var/www-data/
)。 就我而言,我将上传的文件保存到不同的服务器,其中 siteurl 略有不同。 因此 substr 删除了$abs_path
中完全不相关的部分。要解决此问题,您需要设置
preview.wwwroot
配置指令。 如果设置,它将从 getSiteRoot 返回并相应地删除。Moxiecode_ManagerEngine::convertPathToURI
的代码很愚蠢,应该修复,但这个解决方案已经足够好了。TL;DR
Example configuration
www.example.com
has DocumentRoot/var/www-data/
/var/www/uploads/images
static.example.com
with DocumentRoot/var/www
Corresponding settings
preview.wwwroot
to/var/www
filesystem.rootpath
to/var/www/uploads/images
preview.urlprefix
tohttp://static.example.com
(or//static.example.com
)Extended explanation
Happily coding when wild 'ds' appears!
The issue is with
Moxiecode_ManagerEngine::convertPathToURI
that uses a piece of code$uri = substr($abs_path, strlen($root));
where$abs_path
is the "server" path (/var/www/uploads/images/image.png
) and$root
is$root = $this->getSiteRoot();
. By default MCIE tries to "guess" the siteroot url (it guesses wrong/var/www-data/
). In my case I saved the uploaded the files to different server, where the siteurl was little bit different. So the substr removed completely unrelated part of the$abs_path
To fix this, you need to set
preview.wwwroot
config directive. If set, it's returned from getSiteRoot and stripped accordingly.The code of
Moxiecode_ManagerEngine::convertPathToURI
is dumb and should be fixed, but this solution is good enough.由于
relative_urls:
为 true,因此使用document_based_url
生成路径。 尝试将relative_urls:
设置为 false。 以下是一些解释这些选项的文档:MCImageManager:rootpath
MCImageManager:relative_urls
MCImageManager: document_base_url
Since
relative_urls:
is true,document_based_url
is used to generate the path. Try settingrelative_urls:
to false. Here's some documentation which explains the options:MCImageManager:rootpath
MCImageManager:relative_urls
MCImageManager:document_base_url