Laravel + tinymce4 + RoxyFileBrowser

时间:2014-12-09 05:21:00

标签: javascript php laravel tinymce-4 roxy-fileman

所以我在laravel php框架中使用tinymce4和RoxyFileBrowser进行配置

{{ HTML::script('js/tinymce/tinymce.min.js') }}
<script type="text/javascript">
    tinymce.init({
        selector: "textarea",
        theme: "modern",
        skin: 'light',
        plugins: [
            "advlist autolink lists link image charmap print preview hr anchor pagebreak",
            "searchreplace wordcount visualblocks visualchars code fullscreen",
            "insertdatetime media nonbreaking save table contextmenu directionality",
            "emoticons template paste textcolor colorpicker textpattern"
        ],
        toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
        toolbar2: "print preview media | forecolor backcolor emoticons | fontselect fontsizeselect",
        image_advtab: true,
        templates: [
            {title: 'Test template 1', content: 'Test 1'},
            {title: 'Test template 2', content: 'Test 2'}
        ],
        file_browser_callback: RoxyFileBrowser
    });

    function RoxyFileBrowser(field_name, url, type, win) {
      var roxyFileman = '{{ asset('js/tinymce/plugins/fileman/index.html?integration=tinymce4')  }}';
      if (roxyFileman.indexOf("?") < 0) {
        roxyFileman += "?type=" + type;
      }
      else {
        roxyFileman += "&type=" + type;
      }
      roxyFileman += '&input=' + field_name + '&value=' + document.getElementById(field_name).value;
      tinyMCE.activeEditor.windowManager.open({
         file: roxyFileman,
         title: 'File Manager',
         width: 800,
         height: 480,
         resizable: "yes",
         plugins: "media",
         inline: "yes",
         close_previous: "no"
      }, {     window: win,     input: field_name    });
      return false;
    }
</script>

并且有一些关于使用filemanager放置图像的奇怪问题,在tinymce4中单击插入图像按钮然后单击源文本框旁边带放大镜图标的文件夹以调用roxyfilebrowser然后选择图像并返回图像路径源文本框

事情从这里变得奇怪,例如,在我的源文本框中,图像路径是

  

/js/tinymce/plugins/fileman/Uploads/Images/20121008_102000.jpg

但是当我按下oke按钮时,图像将出现在tinymce编辑器中,但当我试图保存它并在我的数据库中看到它保存为这样

<img src="../../js/tinymce/plugins/fileman/Uploads/Images/20121008_102000.jpg" alt="" width="448" height="336" />

图像src前面还有其他内容

  

../../

那么如何解决这个问题呢?所以它将出现在我的数据库中

<img src="/js/tinymce/plugins/fileman/Uploads/Images/20121008_102000.jpg" alt="" width="448" height="336" />

0 个答案:

没有答案