Image Manager in the Editor cannot examine an existing image

4 posts, 1 answers
  1. woaksie
    woaksie avatar
    21 posts
    Member since:
    Feb 2007

    Posted 24 Sep 2009 Link to this post

    I am having an issue with the Image Manager in the RadEditor.

    I insert an image into the editor area using the Image Manager. I then select the image in the editor area and click the Image Manager button again. When the image dialog window opens it is not focused on the image and I cannot see what the properties are. I would expect that I would see my image selected and I should be able to examine and change the properties from the properties tab

    The demo at

    http://demos.telerik.com/aspnet-ajax/editor/examples/filemanagers/defaultcs.aspx

    has the same problem.

    I also have a custom FileBrowserContentProvider for my Image Manager and I can see that when my provider is constructed the first time that the selectedUrl and selectedItemTag parameters are set with the selected image src value but I cannot see what to do with these values. I do pass them to the base constructor in FileBrowserContentProvider.
  2. Answer
    Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 29 Sep 2009 Link to this post

    Hi,

    Please, note that the Image manager is not suitable for this scenario and the recommended way is to use the Set Image Properties dialog. You can call it by right clicking on the image and pressing the Properties item in the content menu.

    For your convenience I wrote the code below which will open the Set Image Properties dialog when the user select an image and presses the Image manager toolbar button:

    <script type="text/javascript"
    function OnClientCommandExecuting(editor, args) 
        if (args.get_commandName() == "ImageManager"
        { 
            var sel = editor.getSelectedElement(); 
            if (sel.tagName == "IMG"
            { 
                 
                editor.fire("SetImageProperties"); 
                args.set_cancel(true); 
            } 
        } 
    </script> 
    <telerik:RadEditor  
     OnClientCommandExecuting="OnClientCommandExecuting" 
     
    runat="server" ImageManager-ViewPaths="~/" ID="RadEditor1"
    <Content><IMG alt="" src="/editorQ3SP22008/Save.gif"></Content> 
    </telerik:RadEditor>  

    If you really need however to highlight the selected image in the file browser when you click on the Image Manager tool then try the code below:

    <script type="text/javascript">  
    /*The code below will allow you to set the PreselectedItemUrl value in the OnClientCommandExecuting event of RadEditor and load the desired location in the Image manager. After that in the OnClientCommandExecuted event you should set the value of oldAdditionalQueryString to null to not apply everytime additional querystring to the dialog when it is being opened:*/ 
     
    var oldAdditionalQueryString = null;  
    function OnClientCommandExecuting(editor, args)  
    {  
            var selectedElement = editor.getSelectedElement();  
            if (!selectedElement || selectedElement.tagName != "IMG")  
            {  
                oldAdditionalQueryString = editor.get_dialogOpener().get_additionalQueryString()  
                //random number is added to make the url unique and force the reload of the dialog.  
                //this way we can ensure that the file will be selected when the dialog loads.  
                editor.get_dialogOpener().set_additionalQueryString(oldAdditionalQueryString + "&rndnum="+ (new Date()-100) + "&PreselectedItemUrl=" + encodeURIComponent("/editorQ1SP12009/Images/test/"));  //in the encodeURIComponent put the desired image folder location parameter 
            }  
    }  
    function OnClientCommandExecuted(editor, args)  
    {  
            if (oldAdditionalQueryString)  
            {  
             editor.get_dialogOpener().set_additionalQueryString(oldAdditionalQueryString);  
             oldAdditionalQueryString=null;  
            }  
    }  
    </script>  
      
    <telerik:RadEditor id="RadEditor1" runat="server" OnClientCommandExecuting="OnClientCommandExecuting" OnClientCommandExecuted="OnClientCommandExecuted">  
        <ImageManager ViewPaths="~/Images" UploadPaths="~/Images" />  
    </telerik:RadEditor>   
     

    Kind regards,
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Daniel Mettler
    Daniel Mettler avatar
    20 posts
    Member since:
    Apr 2003

    Posted 04 Jan 2010 Link to this post

    Rumen, could you add this to the RadEditor core as a feature that can be enabled/disabled by an attribute?
    I believe many users would find that useful.
  5. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 04 Jan 2010 Link to this post

    Hi Daniel,

    Thank you for your feature request. We will consider its implementation for some of next versions of RadEditor.

    Happy New Year,
    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.
Back to Top