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

Forums / Developing with Sitefinity / Accessing library images for custom meta field

Accessing library images for custom meta field

24 posts, 0 answered
  1. Nigel
    Nigel avatar
    38 posts
    Registered:
    01 Dec 2004
    23 Apr 2008
    Link to this post
    Hi

    I would like to present my CMS user with the choice of library images when selecting a thumbnail for a news story (or other custom provider of generic content type). At the moment, the UrlWebEditor is loaded.

    I tried changing the link button command argument as follows:
    <asp:LinkButton ID="picker" runat="server" OnClientClick="javascript:needToConfirm=false;callAjaxFunc=false;" Text="select"  
    CssClass="picker" CausesValidation="false" CommandName="Pick"                                  
    CommandArgument="Thumbnail:Telerik.Libraries.WebControls.ImageSelector, Telerik.Libraries.WebControls"></asp:LinkButton>                         

    This sort of works, but not great. The ImageSelector gets loaded into the dialog box, but the references to the images in the libraries are broken. And, the dialog window is not big enough.

    Is there a way to fix these issues?

    Thanks
  2. Vassil Daskalov
    Vassil Daskalov avatar
    261 posts
    Registered:
    18 May 2013
    29 Apr 2008
    Link to this post
    Hi Nigel,

    Actually, you could remove the picker LinkButton (or set the Visible property to false) as the Images & Documents module provides a control for these cases. It's called ButtonSelector and in order to use it you should first register it on the corresponding template, like this:

    <% @ Register TagPrefix="sfLib" Namespace="Telerik.Libraries.WebControls" Assembly="Telerik.Libraries" %> 

    After that, add the control to the template and associated with the Thumbnails text box, like this:

    <asp:TextBox ID="Thumbnail" Text="" runat="server" MaxLength="250"></asp:TextBox> 
     
    <sfLib:ButtonSelector runat="server" AssociatedControls="Thumbnail" /> 

    Unfortunately, I found a small js bug in the ButtonSelector which you should overcome in order to use that control. You should modify the ~/Sitefinity/Admin/ControlTemplates/Libraries/Dialogs/ButtonSelector.ascx file on line 68, by assuring that the beforeInsertLink method is declared:

    Previous:

    beforeInsertLink(src, altText, title, width, height); 


    After modification:

    if (typeof(beforeInsertLink) != 'undefined') 
        beforeInsertLink(src, altText, title, width, height); 


    Hope this helps.

    Sincerely yours,

    Vassil Daskalov
    the Telerik team


    Instantly find answers to your questions at the new Telerik Support Center
  3. UI Crew
    UI Crew avatar
    99 posts
    Registered:
    24 Sep 2012
    29 Apr 2008
    Link to this post
    Thanks Vassil. I too have been waiting to see an answer come through for this one.

    Thanks again,

    Seth
  4. UI Crew
    UI Crew avatar
    99 posts
    Registered:
    24 Sep 2012
    30 Apr 2008
    Link to this post
    Hi Vassil,

    I implemented that and it works a treat thank you! I am sorry to bug you about these things but I can't find information in the Developer manual about these new controls that can be used - is it me or is there no information this sort of thing?

    Couple of questions for you:

    This dialog box doesn't include the ability to upload a new thumbnail to Images & Docs like the file system one it replaces. This means you have to upload it first before creating a news item... not a big issue at this point Is it possible to include that in the next release or is a different dialog box available for this?

    I am just wondering though is there a way you can get the alt text associated with the image in the Image & Docs module and display it in the control that displays the image in the news list on the public end?

    <asp:Image ID="Thumbnail" ImageUrl='<%#DataBinder.Eval(Container.DataItem, "Thumbnail")%>' runat="server" />


    Thanks,

    Seth

  5. Vassil Daskalov
    Vassil Daskalov avatar
    261 posts
    Registered:
    18 May 2013
    30 Apr 2008
    Link to this post
    Hi Seth Cleaver,

    Thanks for the nice words. Currently, we are working on a revised scheme for the Developer manual, so pretty soon you should see results in this direction.

    The current implementation of the ButtonSelector control does not allow uploading of images inside the selector dialog. However, this feature sounds like a logical one and is already added to our to-do list. Thanks for the insight.

    Unfortunately, I can not see an easy way to get the alternative text from the image stored in the Images & Documents module. Perhaps one way would be to subscribe to the OnExecuting event of the NewsManager. In the event handler get the image assigned for the current news item's Thumbnail property. You should do this via the Libraries API, . Afterwards get the AlternativeText meta data and assign it to some other meta data for the news item. Hope this will fulfill your needs as I can not see any other easy way to implement that. Anyway, your Telerik account has been updated, as both issues you provide were very important to us.

    Best wishes,
    Vassil Daskalov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    30 Apr 2008
    Link to this post

    Hi,

    Could use this way to select not the image thumbnail but the ParentID for the Gallery. I search a way to attach to the news or events the image library.

    Thanks, Pierre

  7. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    08 May 2008
    Link to this post
    Hi Pierre,

    That's correct, you can take the ParentID of a image using Vasil's description.

    Best wishes,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    13 Nov 2008
    Link to this post
    thanks for this post, unfortunately I can't seem to figure out how to make this work inside of a radgrid. I've setup an edittemplate for an image url using an xmldatasource, and everything works fine up until I select the image and select I'm done... it just says Undefined in the textbox!

    I tried to set the Associated control to be both Image (which is the id of the associated textbox) as well as Image.ClientID, and neither seems to work...

    is there a specific change that must be done to use this selector in a radgrid or is this just currently not possible?

    thanks
  9. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    14 Nov 2008
    Link to this post
    i tried running the debugger but inside the OnClientClose function, the argument is indeed coming back as undefined, instead of showing me the selected item. i can't figure out why, as I do select an image...

    any ideas?
  10. Pepi
    Pepi avatar
    981 posts
    Registered:
    08 Dec 2016
    17 Nov 2008
    Link to this post
    Hi Josh,

    Please open a new support ticket and send us all necessary files to test the issue locally.

    Thanks for your cooperation in advance.

    Greetings,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  11. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    17 Nov 2008
    Link to this post
    I submitted the ticket thanks for following up. Please let me know if you need anything further in that ticket. thanks again!
  12. OC
    OC avatar
    129 posts
    Registered:
    17 Nov 2004
    07 Dec 2008
    Link to this post
    Vassil,

    This bug is still in the latest download. I've fiexed this on a 3.2 site, but the error occurred again when upgradiont to 3.5 SP1.

    You shoul correct it for new releases.

    OC
  13. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    08 Dec 2008
    Link to this post
    Hi Ole,

    Thank you for your follow up.
    We apologize for the inconvenience, and will fix this as soon as possible.

    All the best,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  14. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    23 Feb 2009
    Link to this post
    was uploading added to the button selector?

    if not, what is the current correct, best practice for adding an image picker for meta fields? I need one that allows both file uploads and library uploads for the news thumbnails field.
  15. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    06 Mar 2009
    Link to this post
    Hello,

    This is still not implemented.
    Here is what comes to my mind though. You can create a RadWindow, which contains the ItemSelector control. Then the item selector is returning a value to a control in the RadWindow, while the RadWindow passes this value to a control in the control template. I cannot think of any other fast solution at this time.

    Regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  16. Richa
    Richa avatar
    69 posts
    Registered:
    04 Jun 2009
    17 Nov 2010
    Link to this post
    Hello Vassil
    How do you get the guid for the selected library item? (Sf ver (Sf ver 3.7.2136.2:0)

    Thanks
    Richa
  17. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    17 Nov 2010
    Link to this post
    Hello Richa,

    The id is passed as a closeArgument of the RadWindow and this is how we return it back to the associated control. Initially we sent the ID as an onclick attribute of the links that represent each library item - image or document.

    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
  18. Richa
    Richa avatar
    69 posts
    Registered:
    04 Jun 2009
    17 Nov 2010
    Link to this post
    Thanks Ivan.
    But  where do I register for the onclose event of the window, because am not opening it programatically?
    Also, the associatedcontrols only have the url to selected item, do i specify some other attribute for the ButtonSelector which will be populated with the selected item's id?
  19. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    17 Nov 2010
    Link to this post
    Hello Richa,

    Which dialog do you use?

    Kind regards,
    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
  20. Richa
    Richa avatar
    69 posts
    Registered:
    04 Jun 2009
    17 Nov 2010
    Link to this post
    the default 'select an image' window (see attached)

    <asp:TextBox ID="photo" runat="server" MaxLength="250" Text='<%# Bind("PhotoLink") %>'></asp:TextBox>
    <sfLib:ButtonSelector ID="btnPhoto" runat="server" AssociatedControls="photo" CssClass="picker" />
  21. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    17 Nov 2010
    Link to this post
    Hi Richa,

    The dialog that is used on your screenshot is  Sitefinity\Admin\ControlTemplates\Libraries\Dialogs\ItemSelector.ascx. When you click on an item from a library setSelected function is called and "I'm done" button is enabled. After that insertLink() function of Sitefinity\Admin\ControlTemplates\Libraries\Dialogs\ImageEditorDialog.ascx is called and the selected values is returned to the textbox by closeArgument variable which represents the current element.

    Sincerely yours,
    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
  22. Richa
    Richa avatar
    69 posts
    Registered:
    04 Jun 2009
    17 Nov 2010
    Link to this post
    Hello Ivan
    I saw this discussion
    http://www.sitefinity.com/devnet/forums/sitefinity-3-x/developing-with-sitefinity/registering-javascript-event-ot-buttonselector.aspx
    where the user had a problem where the selected item's guid was showing up in the textbox (associatedcontrol) but he wanted to show the item name and still save the guid.
    Was this an old version? because the problem i have right now is that item name is showing up fine in the textbox but i want to save the guid.

    In that discussion, you also showed sample code, where, in order to show the name, you found the textbox by id and set its innerhtml to be the item name. So do i have to do the same for getting the id? or can you provide sample code on how to use closeArgument in the usercontrol where <sflib:ButtonSelector> is declared?
  23. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    17 Nov 2010
    Link to this post
    Hi Richa,

    There is a case where you can see the name and the workaround has been provided here -ButtonSelector producing varying results

    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
  24. Richa
    Richa avatar
    69 posts
    Registered:
    04 Jun 2009
    17 Nov 2010
    Link to this post
    The code is already present in ItemSelector.ascx (you are pointing to the one in \Sitefinity\Admin\ControlTemplates\Libraries\Dialogs, correct?), but i still see the name... Please suggest..
    Your help is appreciated.

    Thank once again Ivan.
Register for webinar
24 posts, 0 answered