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

Insert img tag from ImageManager with border = 0

2 Answers 77 Views
Editor
This is a migrated thread and some comments may be shown as answers.
วรวุฒิ
Top achievements
Rank 2
วรวุฒิ asked on 05 Sep 2009, 11:01 PM
It possible to be add img tag with border="0" properties by default after add new picture in Radeditor?
Because when used we make this picture to picturelink  the browser it showing link border around picture.

Thanks Telerik Team.


Worawut Boontan
Product Manager
TBD
http://www.theiconweb.com


2 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 08 Sep 2009, 03:11 PM
Hello Worawut,

Using the following code you will add border = "0" to all images inserted in the content area through the image manager:

<script type="text/javascript">   
function OnClientPasteHtml(editor, args) {   
    var commandName = args.get_commandName();   
    var value = args.get_value();   
     
    if (commandName == "ImageManager"
    { 
        //See if an img has an alt tag set 
        var div = document.createElement("DIV"); 
         
        //Do not use div.innerHTML as in IE this would cause the image's src or the link's href to be converted to absolute path. 
        //This is a severe IE quirk. 
        Telerik.Web.UI.Editor.Utils.setElementInnerHtml(div,value); 
         
        //Now check if there is alt attribute 
        var img = div.firstChild; 
        img.setAttribute("border""0"); 
        //Set new content to be pasted into the editor 
        args.set_value(div.innerHTML); 
    } 
}      
</script>  
<telerik:RadEditor ID="RadEditor1" runat="server" OnClientPasteHtml="OnClientPasteHtml">   
    <ImageManager ViewPaths="~/images" UploadPaths="~/images" DeletePaths="~/images"/> 
    <Content>  
    </Content>  
</telerik:RadEditor>  

The solution is based on the following live example: OnClientPasteHtml.


Sincerely,
Rumen
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
วรวุฒิ
Top achievements
Rank 2
answered on 08 Sep 2009, 10:00 PM
It work fine. Thanks.


Cheer
Worawut Boontan
Tags
Editor
Asked by
วรวุฒิ
Top achievements
Rank 2
Answers by
Rumen
Telerik team
วรวุฒิ
Top achievements
Rank 2
Share this question
or