This is a migrated thread and some comments may be shown as answers.

IE8 Gets Absolute URL For Image Added From Image Manager

1 Answer 39 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Amy
Top achievements
Rank 1
Amy asked on 13 Apr 2016, 02:51 PM

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?

1 Answer, 1 is accepted

Sort by
0
Accepted
Joana
Telerik team
answered on 18 Apr 2016, 01:52 PM
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.
Tags
Editor
Asked by
Amy
Top achievements
Rank 1
Answers by
Joana
Telerik team
Share this question
or