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

Forums / Developing with Sitefinity / How to access image library

How to access image library

4 posts, 0 answered
  1. Andre
    Andre avatar
    23 posts
    Registered:
    07 Feb 2008
    28 Feb 2012
    Link to this post

    Hi,

    I've this sample to access NewsItem and a related Image to every NewsItem.
    What I need is to just access the Image Library "Thumbnails".
    As I'm a novice with LinQ I can't make it work.

    this
    .RadRotator1.DataSource = App.WorkWith()

                            .NewsItems()

                            .Where(n => n.Status == ContentLifecycleStatus.Live)

                            .Get()

                            .Take(this.NewsLimit)

                            .ToList()

                            .Join(App.WorkWith()

                                    .Images()

                                    .Get()

                                    .Where(i => i.Parent.Title == "Thumbnails" && i.Status == ContentLifecycleStatus.Live),

                                item => item.Title.Value,

                                image => image.Title.Value,

                                (item, image) => new { NewsItem = item, NewsImage = image });

    Can somebody help me please to clean the NewsItem from but keep the typ NewsImage as it is?

    Thanks

    Andre

  2. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    29 Feb 2012
    Link to this post
    Hi Andre,

    You can get a specific library by its name this way:

    var album = App.WorkWith().Albums().Where(p => p.Title == "MYALBUMNAME").Get().SingleOrDefault();

    where MYALBUMNAME is the name of the library.

    All the best,
    Victor Velev
    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. Andre
    Andre avatar
    23 posts
    Registered:
    07 Feb 2008
    01 Mar 2012
    Link to this post
    Hi Victor,

    I get an error when I try to use tihs as DataSource for the RadTree:
    Data source is an invalid type.  It must be either an IListSource, IEnumerable, or IDataSource.

    I'm a novice with LinQ so how can I cast it to the needed datatype?

    Thanks

    Andre
  4. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    05 Mar 2012
    Link to this post
    Hello Andre,

    You can create a list of images from a particular album ( or you can get the album names, depending on what you want to achieve ) and bind them in the TreeView. Please consult our API, which contains examples of how to use the images API:

    http://www.sitefinity.com/documentation/documentationarticles/developers-guide/sitefinity-essentials/modules/media-modules/images/managing-images/querying-images


    You can also check the RadTree demos on our website, in order to understand how it works:

    http://demos.telerik.com/aspnet-ajax/treeview/examples/overview/defaultcs.aspx


    Regards,
    Victor Velev
    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
4 posts, 0 answered