Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Assuming you have ImageFiles setup as a media type (e.g. there is a content type code file called "ImageFile") You can use an IContentRepository to get a list of the images, e.g.
var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>(); var galleryImages = contentRepository.GetChildren<ImageFile>(Folder);
You can use a UrlResolver to get the actual Url of the image:
var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>(); foreach (var image in galleryImages) { var url = urlResolver.GetUrl(image.ContentLink); }
Or if you are in an MVC Razor View you can use the URL helper:
@Url.ContentUrl(image.ContentLink)
Hello All!
I'm relatively new to episerver and was hoping someone could help.
I am trying to get a list of images to show in a gallery by selecting a media folder. Now at the moment I can select the folder however I am at a lost to how to pull the images within the folder.
Below is the code I have at the moment.
[UIHint(UIHint.MediaFolder)]
[Display(
Name = "Folder",
GroupName = SystemTabNames.Content,
Order = 1)]
public virtual ContentReference Folder { get; set; }
Any help than can be given will be greatly appreciated.