IE8 Gets Absolute URL For Image Added From Image Manager

2 posts, 1 answers
  1. Amy
    Amy avatar
    4 posts
    Member since:
    Apr 2006

    Posted 13 Apr Link to this post

    When using IE8, if I add an image to the content in the editor via the Image Manager, the SRC attribute gets an absolute URL. I can reproduce this on your demo at http://demos.telerik.com/aspnet-ajax/editor/examples/filemanagers/defaultcs.aspx. 

    When using IE9 or higher, the SRC gets a virtual path, which is what we want.

    Is there a way to make IE8 get a virtual path?

  2. Answer
    Joana
    Admin
    Joana avatar
    70 posts

    Posted 18 Apr Link to this post

    Hello Amy,

    You could implement a custom content filter to convert the absolute URLs into relative ones. You could find more information here in our documentation.

    For your convenience, I have prepared a sample filter that could be used:

    <script type="text/javascript">
         function OnClientLoad(editor, args)
         {
             editor.get_filtersManager().add(new ConvertToVirtualPath());
         }
         ConvertToVirtualPath = function ()
         {
             ConvertToVirtualPath.initializeBase(this);
             this.set_isDom(false);
             this.set_enabled(true);
             this.set_name("RadEditor ConvertToVirtualPath filter");
             this.set_description("RadEditor ConvertToVirtualPath filter description");
         }
         ConvertToVirtualPath.prototype =
         {
             getHtmlContent: function(content)
             {
                 var regExp = new RegExp("src=[\"'](.+?)[\"'].*?", "gi");
                 var newContent = content.replace(regExp, function(match, offset, fullText)
                 {
                     return match.replace("http://" + window.location.host, "");
                 });
                 return newContent;
             }
         }
         ConvertToVirtualPath.registerClass('ConvertToVirtualPath', Telerik.Web.UI.Editor.Filter);
    </script>

    Set the OnClientLoad event of the RadEditor and add the new filter.

    I hope this will help you achieve your scenario.

    Regards,
    Joana
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top