TinyMCE为图片网址添加额外的斜杠

use*_*393 3 html php tinymce

我正在为一个客户建立的新网站上测试tinyMCE.

这是编辑器的测试页面......

http://simplicity.s462.sureserver.com/editor.php

我遇到的问题是当我进行图像插入并选择其中一个图像时,tinyMCE会在图像网址上添加一个额外的斜杠.结果,找不到图像.当我手动删除额外的斜杠时,会找到图像.

如何防止tinyMCE添加这些额外的斜杠?我确信有一个简单的答案,但我一直在寻找几个小时,我没有找到答案的运气.我究竟做错了什么??

以下是用于填充图像列表的PHP代码:

<?php // this must be the very first line in your PHP file! 

// You can't simply echo everything right away because we need to set some headers first! 
$output = ''; // Here we buffer the JavaScript code we want to send to the browser. 
$delimiter = ""; // for eye candy... code gets new lines 

$output .= 'var tinyMCEImageList = new Array('; 

$directory = "../../images"; // Use your correct (relative!) path here 

// Since TinyMCE3.x you need absolute image paths in the list... 
$abspath = preg_replace('~^/?(.*)/[^/]+$~', '/$1', $_SERVER['SCRIPT_NAME']); 

if (is_dir($directory)) { 
    $direc = opendir($directory); 

    while ($file = readdir($direc)) { 
        if (preg_match('~^.~', $file)) { // no hidden files / directories here... 
             if (is_file("$directory/$file") && getimagesize("$directory/$file") != FALSE) { 
                // We got ourselves a file! Make an array entry: 
                $output .= $delimiter 
                    . '["' 
                    . utf8_encode($file) 
                    . '", "' 
                    . utf8_encode("$abspath/$directory/$file") 
                    . '"],'; 

            } 
        } 
    } 

    $output = substr($output, 0, -1); // remove last comma from array item list (breaks some browsers) 
    $output .= $delimiter; 

    closedir($direc); 
} 
else
{
    echo "false";
}

// Finish code: end of array definition. Now we have the JavaScript code ready! 
$output .= ');'; 

// Make output a real JavaScript file! 
header('Content-type: text/javascript'); // browser will now recognize the file as a valid JS file 

// prevent browser from caching 
header('pragma: no-cache'); 
header('expires: 0'); // i.e. contents have already expired 

// Now we can send data to the browser because all headers have been set! 
echo $output; 

?>
Run Code Online (Sandbox Code Playgroud)

以下是TinyMCE的设置:

        // General options 
    mode : "textareas", 
    theme : "advanced", 
    plugins : "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template", 

    // Theme options 
    theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect", 
    theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", 
    theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", 
    theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage", 
    theme_advanced_toolbar_location : "top", 
    theme_advanced_toolbar_align : "left", 
    theme_advanced_statusbar_location : "bottom", 
    theme_advanced_resizing : true, 
    relative_urls : false,
    convert_urls : false,


    // Example content CSS (should be your site CSS) 
    content_css : "css/example.css", 

    // Drop lists for link/image/media/template dialogs 
    template_external_list_url : "js/template_list.js", 
    external_link_list_url : "js/link_list.js", 
    external_image_list_url : "external_image_list_url.php", 
    media_external_list_url : "js/media_list.js", 
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助!!

Aar*_*ron 5

以下是tinymce网站的几个例子.

他们用额外的../../斜线解决了我遇到的问题.

绝对URL

tinymce.init({
    relative_urls: false
});
Run Code Online (Sandbox Code Playgroud)

具有主机名的绝对URL.

tinymce.init({
    relative_urls: false,
    remove_script_host: false
});
Run Code Online (Sandbox Code Playgroud)

相对网址

tinymce.init({
    relative_urls: true
});
Run Code Online (Sandbox Code Playgroud)

URL相对于给定页面.

tinymce.init({
    selector: '#relurlstopage',
    relative_urls: true,
    document_base_url: 'http://www.tinymce.com/tryit/'
});
Run Code Online (Sandbox Code Playgroud)

不要转换URL

tinymce.init({
    plugins: 'link image code',
    convert_urls: false
});
Run Code Online (Sandbox Code Playgroud)

资料来源:http://www.tinymce.com/tryit/url_conversion.php


Rob*_*son 1

我查看了http://simplicity.s462.sureserver.com/external_image_list_url.php页面。这里的内容有双正斜杠。问题似乎出在提供给 TinyMCE 的列表中。