using Sitecore;
using Sitecore.Data.Items;
using Sitecore.Resources.Media; public string GetUrl()
{
var currentItem = Sitecore.Context.Item;
var imageUrl = string.Empty; Sitecore.Data.Fields.ImageField imageField = currentItem.Fields["Image"];
if (imageField?.MediaItem != null)
{
var image = new MediaItem(imageField.MediaItem);
imageUrl = StringUtil.EnsurePrefix('/', MediaManager.GetMediaUrl(image));
}
} sitecore