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

Forums / Developing with Sitefinity / How to Querying Images from Child Album(Child Folder)

How to Querying Images from Child Album(Child Folder)

3 posts, 0 answered
  1. Ajay
    Ajay avatar
    46 posts
    Registered:
    14 Nov 2013
    12 Jun 2014
    Link to this post

    Hi All,

        I'm Created Folder structure in Image library. Means

         ParentImagelibrary
                        image1, image2, image3.

          I'm able to Get Images from Root Level Library.

         ParentImagelibrary1

                    ChildImagelibrary1

                                 Image1, Image2, Image3

                    How to Get Images from ChildImageLibrary. I write code some thing like but no luck :(

    var allfolders = libraryManager.GetAllFolders(album);
     
            foreach (var fl in allfolders.ToList())
            {
                if (fl.Title == "ChildImagelibrary1")
                {
                    IFolder fl1 = fl;
                    var allimg  =libraryManager.GetImages().Where(i => i.Id == fl1.Id);
                }
            }

    Please Help me how to solve,

     

    Thanks in Advance,


                 

             

     

  2. Nikola Zagorchev
    Nikola Zagorchev avatar
    424 posts
    Registered:
    24 Nov 2016
    13 Jun 2014
    Link to this post
    Hello Ajay,

    You can use this code sample for getting the images from a single folder under a parent album:
    protected IEnumerable<Telerik.Sitefinity.Libraries.Model.Image> QueryImages(string parentAlbumTitle, string folderTitle)
           {
               LibrariesManager manager = new LibrariesManager();
     
               var album = manager.GetAlbums()
                   .Where(f => f.Title == parentAlbumTitle)
                   .FirstOrDefault();
     
               var folders = manager.GetAllFolders(album);
               IEnumerable<Telerik.Sitefinity.Libraries.Model.Image> result = new List<Telerik.Sitefinity.Libraries.Model.Image>();
     
               var folder = manager.GetAllFolders(album).Where(f => f.Title == folderTitle).FirstOrDefault();
     
               if (folder != null)
               {
                   result = manager.GetImages().Where(im => im.FolderId == folder.Id);
               }
     
               return result;
           }


    or this one for all folders:
    protected IEnumerable<Telerik.Sitefinity.Libraries.Model.Image> QueryImages(string parentAlbumTitle)
            {
                LibrariesManager manager = new LibrariesManager();
     
                var album = manager.GetAlbums()
                    .Where(f => f.Title == parentAlbumTitle)
                    .FirstOrDefault();
     
                var folders = manager.GetAllFolders(album);
                IEnumerable<Telerik.Sitefinity.Libraries.Model.Image> result = new List<Telerik.Sitefinity.Libraries.Model.Image>();
     
                foreach (var item in folders)
                {
                    var images = manager.GetImages().Where(im => im.FolderId == item.Id);
     
                    result = result.Concat(images);
                }
     
                return result;
            }


    Regards,
    Nikola Zagorchev
    Telerik
     
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  3. Kaushal
    Kaushal avatar
    0 posts
    Registered:
    21 Jul 2014
    04 Sep 2014 in reply to Nikola Zagorchev
    Link to this post

    Hi Dear,

    How to call this method in Controller.I created a IEnumerable<ImageModel> Image and

    try to calling obj.Image=QueryImage("GalleryTitle");

    but unable to find 

3 posts, 0 answered