TinyMCE/MCImageManager路径问题

发布于 2024-07-25 04:59:46 字数 1398 浏览 5 评论 0原文

我在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情场扛把子 2024-08-01 04:59:46

TL;DR

示例配置

  • 您的网站 www.example.com 具有
  • 您将图像上传到 的 DocumentRoot /var/www-data/ /var/www/uploads/images
  • 您使用 DocumentRoot /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 中完全不相关的部分。

substr('/var/www/uploads/images/image.png', strlen('/var/www-data/')) == 'ds/images/image.png'

要解决此问题,您需要设置 preview.wwwroot 配置指令。 如果设置,它将从 getSiteRoot 返回并相应地删除。

substr('/var/www/uploads/images/image.png', strlen('/var/www/')) == 'uploads/images/image.png'

Moxiecode_ManagerEngine::convertPathToURI 的代码很愚蠢,应该修复,但这个解决方案已经足够好了。

TL;DR

Example configuration

  • your web www.example.com has DocumentRoot /var/www-data/
  • you upload you images to /var/www/uploads/images
  • you serve your images from vhost static.example.com with DocumentRoot /var/www

Corresponding settings

  • set preview.wwwroot to /var/www
  • set filesystem.rootpath to /var/www/uploads/images
  • set preview.urlprefix to http://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

substr('/var/www/uploads/images/image.png', strlen('/var/www-data/')) == 'ds/images/image.png'

To fix this, you need to set preview.wwwroot config directive. If set, it's returned from getSiteRoot and stripped accordingly.

substr('/var/www/uploads/images/image.png', strlen('/var/www/')) == 'uploads/images/image.png'

The code of Moxiecode_ManagerEngine::convertPathToURI is dumb and should be fixed, but this solution is good enough.

仙女山的月亮 2024-08-01 04:59:46

由于 relative_urls: 为 true,因此使用 document_based_url 生成路径。 尝试将 relative_urls: 设置为 false。 以下是一些解释这些选项的文档:

Since relative_urls: is true, document_based_url is used to generate the path. Try setting relative_urls: to false. Here's some documentation which explains the options:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文