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

Image Manager Function Args

1 Answer 93 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Amr Saafan
Top achievements
Rank 2
Amr Saafan asked on 18 Aug 2009, 05:18 PM
In the Image Manager JavaScript Function there are 2 parameters sender and args.
I debugged the args parameter and it contains the following:
1- CurrentDirectory.
2-Result.
3-SelectedItem.

I want to get the inserted image height and width, so I looked for this property or attribute in the above three elements I found Result has a property named height and property named width,
But the problem is it always return 0.

Please advise,

Thank you,
Amr Saafan
Senior Software Developer
http://amrsaafan.blogspot.com
http://groups.yahoo.com/group/Developers_For_Ever

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 21 Aug 2009, 12:55 PM
Hello Amr,

The image manager of version 2009.1.402 includes RadFileExplorer which has a different API for the args parameter. You can get the returned value of the function using args.get_value() method. Here is an example on how to get the image width and height using a DIV element:

<script type="text/javascript">   
function changeImageManager(editor,args)   
{   
        if (args.get_commandName() == "ImageManager")   
        {   
            var callbackFunction = function(sender, args)   
            {   
                //result holds the image element  
                var result = Telerik.Web.UI.Editor.Utils.getOuterHtml(args.get_value());   
                 
                var div = document.createElement("DIV");   
                Telerik.Web.UI.Editor.Utils.setElementInnerHtml(div, result);   
                 
                //First child must be the image!   
                var img = div.firstChild;       
                  
                div.style.overflow = "hidden";   
                div.style.width = "1px";   
                div.style.height = "1px";   
                   
                document.body.appendChild(div);     
                //GET THE IMAGE SIZE   
                alert(img.offsetWidth  + " -- " + img.offsetHeight);   
 
                editor.pasteHtml(div.innerHTML"ImageManager");   
            };   
            args.set_callbackFunction(callbackFunction);   
        }   
}   
</script>   
  
<telerik:radeditor runat="server" ID="RadEditor1" OnClientCommandExecuting="changeImageManager">  
    <ImageManager ViewPaths="~/images" UploadPaths="~/images" />  
</telerik:radeditor>   

For your convenience I have attached my test project.

If you are using an older version just use the same logic by creating a DIV element, append the image to it and get its height and width from the DIV.

Best wishes,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Editor
Asked by
Amr Saafan
Top achievements
Rank 2
Answers by
Rumen
Telerik team
Share this question
or