Try our conversational search powered by Generative AI!

Media Item by path


Previously I could open a VersioningFile using:

var fileVersion = (VersioningFile)HostingEnvironment.VirtualPathProvider.GetFile(imagePath);

How can I do the same thing in the new media system?

May 22, 2014 6:17

Hi Bevan,

Here's the code:

var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>();

IContent content = urlResolver.Route(new UrlBuilder(imagePath));
// cast to MediaData, or ImageFile, or whatever :)
var mediaData = content as MediaData;

Hope this helps

Edited, May 22, 2014 13:02
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.