Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image list in Glass with Sitecore

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?

like image 753
PM. Avatar asked Dec 25 '12 11:12

PM.


1 Answers

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.

like image 69
PM. Avatar answered Oct 05 '22 07:10

PM.