More in this section

Forums / Bugs & Issues / Trouble getting images from Sitefinity galleries

Trouble getting images from Sitefinity galleries

3 posts, 0 answered
  1. Wesley
    Wesley avatar
    17 posts
    Registered:
    08 Nov 2010
    11 Apr 2011
    Link to this post
    I am having an issue with a RadRotator user control that I created. Basically whenever I run the following bit of code, all images in the gallery appear twice. I have the same  issue with a similar query for the news items.

     

     

     

    var images = App.WorkWith().Albums().Where(a => a.Title == title).Get().FirstOrDefault().Images;

     

     

     

     

    foreach (Telerik.Sitefinity.Libraries.Model.Image i in images)

     

     

    {

     

     

     

    Hashtable ht = new Hashtable();

     

     

    ht.Add(

     

    "Url", i.MediaUrl);

     

     

    ht.Add(

     

    "Title", i.Title.ToString());

     

     

    results.Add(ht);

     

    }

    Thanks for your help,
    Wes
  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    30 Oct 2017
    11 Apr 2011
    Link to this post
    Hello Wesley,

    You need to get only the Live status of the images - you can specify this in your code like this:
    var images = App.WorkWith().Albums().Where(a => a.Title == title).Get().FirstOrDefault().Images.Where(i => i.Status == ContentLifecycleStatus.Live);
    The reason why you're getting them doubled do far is because if you do not explicitly specify otherwise you will get all images in the album which contains other states (e.g Master, Temp)

    Best wishes,
    Boyan Barnev
    the Telerik team

  3. Wesley
    Wesley avatar
    17 posts
    Registered:
    08 Nov 2010
    11 Apr 2011
    Link to this post
    Thanks, I knew it had to be a simple answer!
3 posts, 0 answered