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

Image Manager in the Editor cannot examine an existing image

3 Answers 84 Views
Editor
This is a migrated thread and some comments may be shown as answers.
woaksie
Top achievements
Rank 2
woaksie asked on 24 Sep 2009, 09:51 PM
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.

3 Answers, 1 is accepted

Sort by
0
Accepted
Rumen
Telerik team
answered on 29 Sep 2009, 02:02 PM
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.
0
Daniel Mettler
Top achievements
Rank 2
Iron
answered on 04 Jan 2010, 08:42 AM
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.
0
Rumen
Telerik team
answered on 04 Jan 2010, 09:40 AM
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.
Tags
Editor
Asked by
woaksie
Top achievements
Rank 2
Answers by
Rumen
Telerik team
Daniel Mettler
Top achievements
Rank 2
Iron
Share this question
or