douxu9707
2018-09-05 12:33
浏览 399
已采纳

TinyMCE从前端显示正确的图像路径

How i can display the correct url for the image uploaded using TinyMCE? I get a file not found error, this because when I load the created contents on the frontend, the src attribute of the images contained inside the post are referring to my img path like this ../../img/prt/image.jpg, and it's the correct path for the backend, but from the index i need that the src is set to img/prt/image.jpg that is the correct path. Any suggestion?

图片转代码服务由CSDN问答提供 功能建议

如何显示使用TinyMCE上传的图像的正确网址? 我找不到文件错误,这个 因为当我在前端加载创建的内容时,帖子中包含的图像的 src 属性指的是我的img路径,如 ../../ img / prt / image .jpg ,它是后端的正确路径,但是从索引我需要将src设置为 img / prt / image.jpg ,这是正确的路径。 有什么建议吗?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dsfhe34889 2018-09-21 04:41
    已采纳

    I've found a solution for this. After reading the related section of the documentations, I've solved using the convert_urls option of the editor. This is the third time I use this kind of editor, so I didn't know about all available options.

    https://www.tiny.cloud/docs/configure/url-handling/#convert_urls

    example code:

    $(document).ready(function(){
    
      tinymce.init({
        selector: 'textarea',  // change this value according to your HTML
        convert_urls: false
      });
    
    });
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题