Get single image from gallery | Episerver Developer Community

Get single image from gallery

Member since: 2011
Is there a better way to implement this?
var image =
    ImageGalleryHandler.Instance.GetImages(new ImageGalleryCollection(new List<ImageGallery> { blogEntry.ImageGallery }),


#56615 Jan 30, 2012 14:40
  • Member since: 2011

    nice formatting :)

    #56616 Jan 30, 2012 14:41
  • Member since: 2009

    Hi Valdis, 

    It looks like you've got two solutions. Either the one you've posted above, or by creating a query: 

    ImageQuery imageQuery = new ImageQuery();
    imageQuery.ImageGallery = new ImageGalleryCriterion();
    imageQuery.ImageGallery.ID = new IntegerCriterion();
    imageQuery.ImageGallery.ID.Value = CurrentImageGallery.ID;
    ImageCollection images = QueryHandler.Instance.GetQueryResult<Image, ImageCollection>(imageQuery, 1, 1);

    I would probably go for your solution as the GetImages method uses ImageGalleryFactory directly (instead of the QueryFactory), and from a performance point of view it probably has its upsides.

    I find it a bit strange that there isn't an overload for the GetImages method that accepts an ImageGallery instead of an ImageGalleryCollection, but I'm sure there's a good reason for it :)

    Hope this helps!


    #56622 Jan 31, 2012 9:02
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
Please login to post a reply