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

LinkManager extension

2 Answers 53 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
Fit2Page asked on 08 Dec 2009, 12:57 PM
Hi,

The LinkManager is now extended with the DocumentManager button, that works great.

I need the same functionality with the Image Manager.
I tried to copy and rework the DocumentManager code, but I am stuck on how to get the parameters back to the LinkManager form.

Is there any chance that this functionality can be added?

Marc

2 Answers, 1 is accepted

Sort by
0
Accepted
Dobromir
Telerik team
answered on 11 Dec 2009, 09:40 AM
Hi Marc,

In order to get the parameters back to the LinkManager you need to modify the callback function. The difference between document and image managers is the element that you are working with so you have to make the following changes:
1) the link.tagName should be IMG not A 
2) the attribute that you have to set as a href should be src
3) the _linkText.value should be changed so it outputs the needed string (<img> tag in my code>

Here is an example of the modified function:

var callbackFunction = Function.createDelegate(this, function(sender, args) {
    var link = args.get_value ? args.get_value() : args.Result;
    if (link && link.tagName == "IMG") {
        var href = link.getAttribute("src", 2);
        this._linkUrl.value = href;
        if (!this._linkText.value) this._linkText.value = "<img src=\"" + href + "\" />";
        var className = link.className;
        if (className) this._linkCssClass.set_value(className);
    }
});

Also, in order to place the image as a link in the editor's content area, you need to replace &lt; and &gt; which will replace  < and > when the editor executes pasteHtml to place the linkText.value. You can do this by using the following approach:

<telerik:RadEditor ID="RadEditor1" runat="server" OnClientPasteHtml="OnClientPasteHtml" ExternalDialogsPath="~/EditorDialogs"
    <ImageManager UploadPaths="~/Images/" ViewPaths="~/Images/" DeletePaths="~/Images/" />
</telerik:RadEditor> 
<script type="text/javascript">
    function OnClientPasteHtml(sender, args) {
        var commandName = args.get_commandName();
        var value = args.get_value();
        debugger;
        if (commandName == "LinkManager") {
            value = value.replace(/\<(.*)>/gi, "<$1>");
              
            args.set_value(value);
        }
    }
</script>

I hope this information helps.


Sincerely yours,
Dobromir
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
answered on 16 Dec 2009, 08:01 AM
Thank you Dobromir , works OK!
Tags
Editor
Asked by
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Dobromir
Telerik team
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or