If you have a sublayout that needs to get the URL of a media item, such as an image (item[“Image”]), here is a quick tip on how you can get that media URL.

 

Item item = Sitecore.Context.Item;

Sitecore.Data.Fields.ImageField imgField = ((Sitecore.Data.Fields.ImageField)item.Fields["Image"]);

string url = Sitecore.Resources.Media.MediaManager.GetMediaUrl(imgField.MediaItem);

string altText = imgField.Alt;