Image list in Glass with Sitecore
Asked Answered
W

1

5

I am using Glass library as ORM for Sitecore. I have a field Images which contains the list of images. Since I want to access this from my .NET code, I have written a partial class which has the field images like:

[SitecoreField]
public virtual IEnumerable<Glass.Sitecore.Mapper.FieldTypes.Image> Images { get; set;}

But while loading this I am getting error.

The method or operation is not implemented.

Where as I am able to access the single image through Glass, without writing any additional code.

Can anyone please suggest something to fix this?

Welcome answered 25/12, 2012 at 11:58 Comment(2)
What is the type of your 'Images' field in your Sitecore template? I'm guessing treelist, or multilist. I don't know anything about the Glass library, but I'm guessing that the problem lies with the fact that it expects to map an image field in sitecore to it's own image class. Remember that sitecore stores multilist/treelist fields as a pipe-separated list of GUIDs, whereas images are stored quite differently - select View->Raw Values to see how it stores image fields.Sadick
Thanks @mdresser for your help. But this was problem with the Glass library mapping. For which work around is as below.Welcome
W
8

Our architect has solved this issue with the help of creator of Glass library. And the solution is like this..

    [SitecoreField]
    public virtual IEnumerable<MediaImage> Images { get; set;}

And Media Image is class like:

     [SitecoreClass]
public class MediaImage
{
    [SitecoreField("Attachment")]
    public virtual Stream Image { get; set; }

    [SitecoreInfo(SitecoreInfoType.MediaUrl)]
    public virtual string Url { get; set; }

    [SitecoreField("Alt")]
    public virtual string Alt { get; set; }
}

This has solved the issue and I am getting the list of images now.

Welcome answered 28/1, 2013 at 6:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.