More in this section

Forums / Developing with Sitefinity / Custom Image Field for Lists

Custom Image Field for Lists

9 posts, 0 answered
  1. Chris Salas
    Chris Salas avatar
    9 posts
    Registered:
    26 Oct 2009
    16 Aug 2011
    Link to this post
    I have been looking for this with no success.  I am trying to add a custom image field for a list.  Can someone point me in the right direction.  Is this possible?  I need to be able to allow my users to select or upload an image for a specific list.  Any help on this is appreciated.
  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Sep 2017
    19 Aug 2011
    Link to this post
    Hello Chris ,

    One option is to create a custom field of type long text which will allow you to use image manager and select images from your computer or images module.

    Another is to create a custom control to be used as custom field which will use <sf:EditorContentManagerDialog runat="server" ID="asyncImageSelector" DialogMode="Image" Width="540" HostedInRadWindow="true"  BodyCss /> <sfFields:FormManager id="formManager" runat="server"/>

    Best wishes,
    Stanislav Velikov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Peter
    Peter avatar
    42 posts
    Registered:
    22 Aug 2011
    22 Aug 2011
    Link to this post
    Hello Stanislav,

    I've got a question about your second suggestion. I have added the following lines for my custom widget (FormManager included):

    <sf:EditorContentManagerDialog runat="server" ID="asyncImageSelector" DialogMode="Image" Width="540" HostedInRadWindow="true" />

    When I run my site I see my new image manager in my widget. But when I try to use it, I get the following javascript error:

    Microsoft JScript runtime error: Unable to get value of the property 'get_contentFrame': object is null or undefined

    What am I doing wrong? Furthermore, how can I finally save the image into my context? 

    Maybe you've got an example how to use the sitefinity image manager for your own custom widget?
     
    Best regards!
    Peter
  4. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Sep 2017
    22 Aug 2011
    Link to this post
    Hello Peter,

    I have attached a working sample of EditorContentManagerDialog user control that can be reused for modules and custom fields. You will have to set the .js files as embedded resources and them in assemblyInfo.cs
    [assembly: WebResource("SitefinityWebApp.Controls.Resources.Scripts.ImageSelectorDialog.js", "application/x-javascript")]

    Register virtual paths needed for the templates to be called(they are embedded resource too). The Global.asax file is used to call the dialog in radwindow.

    All the best,
    Stanislav Velikov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  5. Peter
    Peter avatar
    42 posts
    Registered:
    22 Aug 2011
    23 Aug 2011
    Link to this post
    Hello Stanislav,

    thank you for your reply. However, I cannot figure out how to use the ImageSelector in my custom widget. I have successfully added the files to my project, but how do I get the ImageSelectorDialog in my widget (AddEdit-) ascx?

    Thanks again!
  6. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Sep 2017
    26 Aug 2011
    Link to this post
    Hi Peter,

    Attached is a sample project that has the image selector registered and placed on a page. You can review how it is added in the project. The administrator credentials are (admin/password). A virtual path is registerred for the control you can review it in Administration->Settings->Advanced->VirtualPathSettings->VirtualPaths (Ctrls).
    The sample functions with having RadWindow on a control (SelectorUserControl.ascx) and it calls another .ascx file which contains the dialog. The dialog is an embedded resource so it can only be called with the registered virtual path Ctrls.

    Best wishes,
    Stanislav Velikov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  7. Peter
    Peter avatar
    42 posts
    Registered:
    22 Aug 2011
    26 Aug 2011
    Link to this post
    Hi Stanislav,

    Thank you for your example, it's already up and running. I'll keep you posted when I have successfully added the ImageSelector to my custom widget.

    Best regards,
    Peter
  8. Francisco
    Francisco avatar
    7 posts
    Registered:
    14 Sep 2010
    31 Aug 2011
    Link to this post
    Hi Stanislav,
    I'm using Sitefinity 4.2 but I do not recognize properties or methods that are inherited, for example LayoutTemplatePath. There is some example with the new version?
  9. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Sep 2017
    07 Sep 2011
    Link to this post
    Hello Francisco,

    The layout template path is a way to add reference to .ascx which has a build action set to embedded resource. When  you want to use this embedded resource you have to call it from the assembly trough virtual path.
    Here is a sample in the documentation. I have attached a custom control for your reference. Also this topic describes the whole process.

    All the best,
    Stanislav Velikov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

9 posts, 0 answered