More in this section

Forums / Developing with Sitefinity / Change (or remove) the "Where to upload" box on Image control

Change (or remove) the "Where to upload" box on Image control

17 posts, 0 answered
  1. Damian
    Damian avatar
    42 posts
    Registered:
    25 Mar 2008
    22 Jul 2008
    Link to this post

    Hi all.

    On the image control, basic properties tab, underneath the upload box there is a sentence:

    The image will be uploaded in:  "A Library Name" library.

    and then a change link to open the where to upload box.


    I am looking to remove this functionality or default it so when uploading an image it always uploads to ~/Images and never to a library on this control.  I want to limit uploading images to libraries to the Images & Documents module.


    Can anyway suggest a way in which I can acheive this?

    I am using SP 3.2 SP1, so can you let me know if this is different in one of the newer releases.


    Many thanks in advance

    Damian

  2. Damian
    Damian avatar
    42 posts
    Registered:
    25 Mar 2008
    23 Jul 2008
    Link to this post
    I'm also looking to do this across the board on all RadEditors so that Images can only be added to libraries through the images and documents module.

    Also is there a way you can set the document and file manager within radeditor so that the user cannot download the attachment.

    To explain further, Say I have a news article with an attachement (uploaded in the content radeditor section) can I make it so the file is viewable and not downloadable??

    Thanks

    Damian
  3. Joe
    Joe avatar
    138 posts
    Registered:
    24 Sep 2012
    24 Jul 2008
    Link to this post
    Hi Damian,

    Thanks for contacting us.

    When you place the image control on the page, you can set it to upload images in the ~/Images folder of your application in SF 3.2 SP1. To do so, follow these instructions:
    1. Place the Image control on the page
    2. Click on the Edit button
    3. Click on the Advanced Tab
    4. Under the ImageURL property, type in ~/Images
    5. Click on the Basic Tab
    6. Click on Change in this area : The image will be uploaded in: Images library (Change)
    7. Select ~/Images from the Radio Button list
    I hope that I have given you clear instructions on how to implement your desired functionality. If you have any questions, feel free to contact us.

    Best wishes,
    Joe

    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  4. Damian
    Damian avatar
    42 posts
    Registered:
    25 Mar 2008
    24 Jul 2008
    Link to this post
    *sigh*

    I understand how to do that.  It seems that I must never write clearly on this forum or the questions are not read very carefully.

    Anyway.....

    I want to remove the need for the user doing these steps by setting the image control to always save to ~/images and never to anywhere else.
  5. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    25 Jul 2008
    Link to this post
    Hi Damian,

    Sorry for the misunderstanding.

    As far as I understand, you want to alter this choosing library or folder functionality. In order to do this for the Image control in the Edit Page Toolbox, you have to change this file: \Sitefinity\Admin\ControlTemplates\Libraries\Dialogs\ImageEditorDialog.ascx

    In order to do this for the image dialog in the Generic Content Editor, you have to change this file:
    \Sitefinity\UserControls\Dialogs\ImageEditorDialog.aspx

    Let us know if you need further assistance.

    All the best,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Damian
    Damian avatar
    42 posts
    Registered:
    25 Mar 2008
    30 Jul 2008
    Link to this post
    Thanks Georgi,  It seems when I try and remove anything from these files it throws exceptions saying elements are required.

    \Sitefinity\Admin\ControlTemplates\Libraries\Dialogs\ImageEditorDialog.ascx


    I want to remove the section

    <p>

    <asp:Literal runat="server" Text='<%$Resources:UploadIn %>'></asp:Literal>

    <em id="uploadLibrary"><asp:Literal runat="server" ID="selectedValue"></asp:Literal></em><span id="uploadLocationType"> library</span>

    <a href="javascript:toggleClass('uploadSelectedInLibrary','changeUploadDirection');" id="changeLink">(<asp:Literal runat="server" Text="<%$Resources:Change %>"></asp:Literal>)</a>

    </p>

    <div id="changeDiv">

    <sfLib:LibrarySelector TemplatePath="~/Sitefinity/Admin/ControlTemplates/Libraries/Dialogs/BaseGuidSelectorTemplate.ascx" ID="GuidSelector" runat="server" SelectSpecificItemsText="<%$Resources:ChooseLibrary %>" />

    <p class="closeArea"><a href="javascript:toggleClass('uploadSelectedInLibrary','');">Close</a></p>

    </div>

    and set the control to always upload to ~/images. 


    I have experimented with setting different controls and trying default (and remove) some controls from ~/Sitefinity/Admin/ControlTemplates/Libraries/Dialogs/BaseGuidSelectorTemplate.ascx

    but as I mentioned before I only ever get errors about missing required controls.

    Please can you help me.

    Thanks

    Damian
  7. Vassil Daskalov
    Vassil Daskalov avatar
    261 posts
    Registered:
    18 May 2013
    31 Jul 2008
    Link to this post
    Hello Damian,

    Indeed there are some controls which are set as required for this control. However you can hide them by wrapping them with a placeholder and set its Visible value to false. This way the hidden controls again will be processed by the server but the time used will be insignificant:

    <asp:PlaceHolder runat="server" Visible="false">  
        <p> 
            <asp:Literal runat="server" Text='<%$Resources:UploadIn %>'></asp:Literal> 
            <em id="uploadLibrary"><asp:Literal runat="server" ID="selectedValue"></asp:Literal></em><span id="uploadLocationType"> library</span> 
            <href="javascript:toggleClass('uploadSelectedInLibrary','changeUploadDirection');" id="changeLink">(<asp:Literal runat="server" Text="<%$Resources:Change %>"></asp:Literal>)</a> 
        </p> 
        <div id="changeDiv">  
            <sfLib:LibrarySelector TemplatePath="~/Sitefinity/Admin/ControlTemplates/Libraries/Dialogs/BaseGuidSelectorTemplate.ascx" ID="GuidSelector" runat="server" SelectSpecificItemsText="<%$Resources:ChooseLibrary %>" /> 
            <class="closeArea"><href="javascript:toggleClass('uploadSelectedInLibrary','');">Close</a></p>  
        </div> 
    </asp:PlaceHolder> 

    Give us a sign if this does not make the trick.

    Regards,
    Vassil Daskalov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  8. Damian
    Damian avatar
    42 posts
    Registered:
    25 Mar 2008
    01 Aug 2008
    Link to this post
    Thanks,

    When I do this change I get the following error when clicking upload.

    Also, even if this section was not visible the image would still be uploaded into the first selected library.  I want the image uploaded to ~/images.

    Thanks

    Damian

     

    Server Error in '/TestNew' Application.

    Object reference not set to an instance of an object.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [NullReferenceException: Object reference not set to an instance of an object.]
       Telerik.Cms.Web.UI.BaseGuidSelector.UpdateSelectedIds() +35
       Telerik.Cms.Web.UI.BaseGuidSelector.get_Value() +12
       Telerik.Libraries.WebControls.ImageEditorDialog.UploadButton_Command(Object sender, CommandEventArgs e) +432
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +105
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +163
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
    


    Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832
  9. Slavo
    Slavo avatar
    295 posts
    Registered:
    24 Sep 2012
    04 Aug 2008
    Link to this post
    Hello Damian,

    Unfortunately the logic for selecting the default location for uploading Images is embedded in code and cannot be changed from the template, you can only hide or show controls from there. The default behavior is that if you have one or more libraries created, the first one will always be selected for uploading images. You can of course select the ~/Images folder to upload the images, but this has to be done manually every time you drop an Image control on a page.
    We've logged this in our to-do list and will make it more flexible for the next major version. Please excuse us for the inconvenience.

    Kind regards,
    Slavo
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  10. Kevin Pipher
    Kevin Pipher avatar
    91 posts
    Registered:
    30 Nov 2005
    10 Sep 2008
    Link to this post
    Hi everyone,

    I'm having a similar issue, so I thought I'd reply here rather than open a new thread.

    When using the insert image dialog within the generic control in v3.2 sp2, I want to force the user to select only existing images from the image libraries. Ideally, I'd just like to hide the entire 'upload' section of the modal window and just have the 'select from already uploaded images' functionality remain.

    We're trying to completely centralize image management to avoid people insert/uploading images to incorrect locations.

    The exact functionality I'm looking for is:

    1. User edits page
    2. User edits generic content on page
    3. User clicks "insert image" icon
    4. User is forced to select from image libraries (no option to upload)

    I've looked through the /Sitefinity/UserControls/Dialogs/ImageEditorDialog.ascx file which I believe is the template for the generic content image editor. The problem is the only control is:

    <lib:ItemSelector runat="server" ShowMode="All" AllowPageSelection="false"/>

    I can't access the markup to contain and hide certain tags as discussed above...

    Any suggestions would be greatly appreciated.

    Thanks,
    Kevin.
  11. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    18 Sep 2008
    Link to this post
    Hi Kevin Pipher,

    The control is already compiled that's why you will not be able to access its code and modify it. The problem is also that there is a user control responsible for the file uploads, which is also holding the <lib:ItemSelector> control.

    We suggest you creating a new RadEditor dialog for your scenario. A RadEditor dialog could be a simple ASPX file. You should include the ItemSelector (Telerik.Libraries.WebControls.Dialogs.ItemSelector) control in that dialog. I believe this will solve your problem.

    Don't hesitate to contact us if you have other questions.

    Best wishes,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  12. Damian
    Damian avatar
    42 posts
    Registered:
    25 Mar 2008
    19 Sep 2008
    Link to this post
    Hi Georgi,

    is it possible that you (or anyone else) could post an example of this radeditor and itemselector implementation?

    Thanks

    Damian
  13. Sonya
    Sonya avatar
    231 posts
    Registered:
    24 Sep 2012
    26 Sep 2008
    Link to this post
    Hi Damian,

    We plan to provide the example but we currently do not have the necessary resources (we do not have a time frame for that). What you could do in the mean time is to reflect the following class: Telerik.Libraries.WebControls.Dialogs.ImageEditorDialog.cs
    This will be our example as well.

    Hope this helps.

    Regards,
    Sonya
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  14. Kevin Pipher
    Kevin Pipher avatar
    91 posts
    Registered:
    30 Nov 2005
    27 Oct 2008
    Link to this post
    Hi everyone,

    Until Telerik has a chance to provide some samples on how to accomplish the custom dialogs, I've created a reliable workaround for hiding the 'upload' functionality and forcing the user to select from existing libraries for both images and documents.

    While using the Generic Content control and clicking the "Insert Document" or "Insert Image" buttons, normally we have the choice to either upload a file or select an existing library item.  In my case I want the user to always pick from existing library items.

    To accomplish this, I forced the selection of existing library items by making the following changes:

    1. /Sitefinity/Admin/UserControls/Dialogs/ImageEditorDialog.aspx

    <body onload="setTimeout('openDialog()', 1)"
        <form id="form1" runat="server"
            <div> 
                <asp:ScriptManager ID="ScriptManager" runat="server" /> 
                <lib:ImageEditorDialog runat="server" DisplayMode="Images" /> 
            </div> 
        </form> 
    </body> 

    In the above, all I did was add onload="setTimeout('openDialog()', 1)" to the body tag. This basically means when the user control loads up, the dialog to select an existing library item is forced open.


    2. /Sitefinity/Admin/UserControls/Dialogs/DocumentEditorDialog.aspx

    <body onload="setTimeout('openDialog()', 1)"
        <form id="form1" runat="server"
        <div> 
            <asp:ScriptManager id="ScriptManager" runat="server"/> 
            <lib:ImageEditorDialog runat="server" DisplayMode="Documents" /> 
        </div> 
        </form> 
    </body> 

    Again, just added onload="setTimeout('openDialog()', 1)" to the body tag.


    3. /Sitefinity/Admin/Themes/Default/CustomDialogs.css

    In the dialogs css file, I simply modified the existing uploadPane class to:

    .uploadPane{  display:none; }


    And that's it. Now when you click on Insert Document or Insert Image, the library item selector shows up automatically. The ability to upload new items is hidden.

    You might also be wondering why I used setTimeout rather than calling openDialog directly. It seems that only in Internet Explorer, calling openDialog() directly during body onload does nothing (other browsers work). By adding setTimeout with a tiny delay, the call to openDialog() works correctly.

    Hope this helps some of you until Telerik has a chance to show how to do a custom dialog.

    Kevin.
  15. Kevin Pipher
    Kevin Pipher avatar
    91 posts
    Registered:
    30 Nov 2005
    28 Oct 2008
    Link to this post
    Just to add to my previous post, I realize some other dialog user controls make use of the uploadPane so hiding it using css causes some ill effects to the Link editor and other controls.

    To fix this, I simply added a new class to the css file:

    .uploadPane { padding:20px;}
    .forcedDialog .uploadPane {display:none !important;}

    I then add the class forcedDialog to the containing div tag in whichever dialog user controls I wish, such as the Document selector:

     
    <div class="forcedDialog"
       <asp:ScriptManager id="ScriptManager" runat="server"/> 
       <lib:ImageEditorDialog runat="server" DisplayMode="Documents" /> 
    </div> 

    Hope this helps...
  16. Sonya
    Sonya avatar
    231 posts
    Registered:
    24 Sep 2012
    28 Oct 2008
    Link to this post
    Hi Kevin Pipher,

    Thank you for providing a solution for another member of the Sitefinity community. We have updated your Telerik points.

    Greetings,
    Sonya
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  17. jcrichto
    jcrichto avatar
    35 posts
    Registered:
    14 Aug 2012
    03 Feb 2009
    Link to this post
    I case others haven't see this... very helpful.

    http://www.selarom.com/blog/08-12-17/Sitefinity_File_Manager_Default_Folder.aspx
Register for webinar
17 posts, 0 answered