+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / ImageEditorDialog default upload path

ImageEditorDialog default upload path

4 posts, 0 answered
  1. Chris Darby
    Chris Darby avatar
    1 posts
    Registered:
    14 Feb 2010
    15 Feb 2010
    Link to this post
    Hi,

    I am trying to modify the ImageEditorDialog so that instead of defaulting to one of the libraries we have created to upload an image, it defaults to the ~/Images folder for uploads.

    Can this be done, I am stuck?

    Any help would be great
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Feb 2010
    Link to this post
    Hello Chris Darby,

    You need to create a custom selector that inherits from LibrarySelector. Override CreateChildControls().

    sample code

       public class CustomBaseGuidSelector : LibrarySelector
        {
      
            private ILibrary library;
            private Panel dialog;
            private ImageEditorDialog UploadFolder;
      
            public CustomBaseGuidSelector()
            {
            }
      
            public override string TemplatePath
            {
                get
                {
                    return "~/Sitefinity/Admin/ControlTemplates/Libraries/Dialogs/BaseGuidSelectorTemplate.ascx";
                }
              
            }
      
            protected override void CreateChildControls()
            {
                Control parent = this.Parent;
                while (parent != null && !(parent is Panel))
                {
                    parent = parent.Parent;
                }
                dialog = parent as Panel;
      
                // change the default folder for upload
                parent = this.Parent;
                while (parent != null && !(parent is ImageEditorDialog))
                {
                    parent = parent.Parent;
                }
                UploadFolder = parent as ImageEditorDialog;
                UploadFolder.DefaultUploadFolder = "~/SomeFolder/Folder/";
                // call the base class and set the property
                base.SelectAllItemsText = UploadFolder.DefaultUploadFolder;
      
                base.CreateChildControls();
          }
    }

    Finally you have to change the ImageEditorDialog template  ~/Sitefinity/Admin/ControlTemplates/Libraries/Dialogs/ImageEditorDialog.ascx


    Register the custom selector


    <%@ Register Assembly="App_Code" Namespace="HERE TYPE THE CUSTOM CONTROL NAMESPACE" TagPrefix="sfLib" %> 

    Disable the Label control with ID="SelectedValue" and add new Literal control as below:

    <p>
                      <asp:Literal ID="Literal2" runat="server" Text='<%$Resources:UploadIn %>'></asp:Literal>
                      <em id="uploadLibrary"><asp:Literal Visible="false" runat="server" ID="selectedValue"></asp:Literal>
                      <asp:Literal ID="LibName" runat="server" Text="" ></asp:Literal>
                      </em><span id="uploadLocationType"> library</span>
                      <a href="javascript:toggleClass('uploadSelectedInLibrary','changeUploadDirection');" id="changeLink">(<asp:Literal ID="Literal3" runat="server" Text="<%$Resources:Change %>"></asp:Literal>)</a>
                  </p>


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. David
    David avatar
    1 posts
    Registered:
    02 Dec 2010
    02 Dec 2010
    Link to this post
    I would like to implement almost the same functionality but with the difference that i want to be able to determine the path destination by considering the current page being edited.  I can't manage to get a reference to the page node, how can this be achieved?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    02 Dec 2010
    Link to this post
    Hi David,

    You can use window.parent.location to get the page on which you open the dialog.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
4 posts, 0 answered