Get Images from a particular Album using fluent API

Posted by Community Admin on 03-Aug-2018 22:06

Get Images from a particular Album using fluent API

All Replies

Posted by Community Admin on 09-Dec-2010 00:00
Hi,

I have developed a control for a custom image gallery which outputs a unordered list of images however I can't seem to work out a method of pulling the images out of a particular album "just" by Album Name using the Fluent API (or the standard API for that matter)

I am using this code below but can't find how I can modify it to utilise AlbumName with out running into permission issues when the control is in the public frontend:

public IQueryable<Telerik.Sitefinity.Libraries.Model.Image> FindGalleryImages(string AlbumName)
        
            return App.WorkWith()
                        .Images()
                        .Where(i => i.Status == ContentLifecycleStatus.Live && i.Width > 900)
                        .OrderBy(y => y.Title).Get();
        

This is a public control so any code I use must not need a user with admin permissions (I tried a couple of methods in the API but whenever I tried to view the page with an anonymous user the images would then not show.

The site is now live but the image gallery on the product pages are exactly the same because the API will not allow my image list to be filtered by a particular Album. You can view the image gallery in production (without filtering):


Thanks,

Seth
Posted by Community Admin on 11-Dec-2010 00:00
Hello Webinsite,

Thank you for using our services.

Can you try using the same code as in the SDK sample Coverflow and Book widgets? Bellow is the code snippet used by those controls:
private List<Hashtable> GetImages()
    List<Hashtable> results = new List<Hashtable>();
    string title = this.AlbumTitle;
 
    ////get IQueryable of images from the Fluent API.
    var images = App.WorkWith().Images()
        .Where(
        (w) => w.Parent.Title == title &&
               w.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live)
         .Get();
 
    var authority = this.GetAuthorityUrl();
    foreach (Telerik.Sitefinity.Libraries.Model.Image v in images)
    
        Hashtable table = new Hashtable();
        table.Add("Url", authority + v.MediaUrl);
        table.Add("Title", v.Title.ToString());
        results.Add(table);
    
 
    return results;

You can also try this piece of code:
var images = App.WorkWith().Albums().Where(a => a.Title == "AlbumTitle").Get().FirstOrDefault().Images;


Regards,
Radoslav Georgiev
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
This thread is closed