and , when rendering a MediaItem, generate html code that looks like the following:
Create a Link to Sitecore Media Item
You will not be able to fetch the Media Item using the above LinkManager.GetItemUrl() Method. Sitecore has a separate API to fetch the Media URLs.
public string ResolveSitecoreMediaURL(Sitecore.Data.Items.Item item)
{
MediaUrlOptions mediaOptions= new MediaUrlOptions();
mediaOptions.AlwaysIncludeServerUrl = true;
mediaOptions.AbsolutePath =true;
return Sitecore.Resources.Media.MediaManager.GetMediaUrl(item,mediaOptions);
}
Like LinkManager had the URLOptions MediaManager comes with a MediaUrlOptions where you can control the absolute and relative URLs.