I'm new to EPiServer and I am trying to get all the MediaData from a local folder of a page that is not the root. I have tried to get it with the following code but I get zero back. I am doing something wrong because I have a file in my currentPage? Any ideas?
Check out the contentassetshelper class and the GetOrCreateMediaAssetsFolder method.
Then you can list children from that one...the method above will return an assets folder which has a content link property. Use that in your list children method above as root.
I have tried it but I do not get the files under currentPage using GetOrCreateAssetFolder.
var contentAssetFolder = contentAssetHelper.GetOrCreateAssetFolder(CurrentPage.ContentLink);
I have tried getting all children using the abov without getting my file.
Have you tried.GetChildren<IContent>(contentAssetsFolder)?
That should give you everything in page files. In your above code you are asking for any children of type content folder, so it won't give you normal images etc.
Thank you :)! Works like a charm!
Sweet! Remember to filter them on access rights and publish status since GetChildren doesn't do that by default. :)
I normally use FilterForVisitor in Episerver.Filters namespace...or an extension that looks a little prettier.