How to Querying Images from Child Album(Child Folder)

Posted by Community Admin on 04-Aug-2018 11:13

How to Querying Images from Child Album(Child Folder)

All Replies

Posted by Community Admin on 12-Jun-2014 00:00

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,


             

         

 

Posted by Community Admin on 13-Jun-2014 00:00
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
 
Posted by Community Admin on 04-Sep-2014 00:00

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 

This thread is closed