ASPX templates
Version 5.x > ASPX templates > Media Library API Class View modes: 
User avatar
Member
Member
luke-gatecrasher.com - 3/28/2011 11:23:47 PM
   
Media Library API Class
MediaFileInfo mediaInfo = MediaFileInfoProvider.GetMediaFileInfo(int.Parse(ImageID));
MediaLibraryInfo libraryInfo = MediaLibraryInfoProvider.GetMediaLibraryInfo(mediaInfo.FileLibraryID);

String urlFile = MediaFileInfoProvider.GetMediaFileUrl(mediaInfo.FileGUID, mediaInfo.FileName);

Gives me a really ugly image url of ~/getmedia/68c08a8f-59ab-4364-8fb2-6fa802a358c4/Desert.aspx

Is there a method for getting the pretty url such as
http://localhost/SiteName/media/test/Desert.jpg?

User avatar
Member
Member
kentico_michal - 3/29/2011 7:11:52 AM
   
RE:Media Library API Class
Hi,

Could you please try to use following code:
MediaFileInfo mediaInfo = MediaFileInfoProvider.GetMediaFileInfo(imageID);

MediaLibraryInfo libraryInfo = MediaLibraryInfoProvider.GetMediaLibraryInfo(mediaInfo.FileLibraryID);

String urlFile = MediaFileURLProvider.GetMediaFileUrl(mediaInfo, CMS.CMSHelper.CMSContext.CurrentSiteName, libraryInfo.LibraryFolder);

Best regards,
Michal Legen

User avatar
Member
Member
luke - 3/29/2011 8:59:37 PM
   
RE:Media Library API Class
Thats it cheers

User avatar
Member
Member
Jon.East - 10/24/2013 9:59:01 AM
   
RE:Media Library API Class
what is the imageID in this code example? CMSEditableImage.?

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 11/4/2013 10:58:54 AM
   
RE:Media Library API Class
Hello Jon,

The ImageID in this method is Media file ID.

Additional details about the parameters can be found in the API Reference.

Best regards,
Martin Danko