Skip to content

Instantly share code, notes, and snippets.

@RyanABailey
Created October 30, 2014 05:12
Show Gist options
  • Select an option

  • Save RyanABailey/84447ae0bdf9c0238d75 to your computer and use it in GitHub Desktop.

Select an option

Save RyanABailey/84447ae0bdf9c0238d75 to your computer and use it in GitHub Desktop.
sitecore get image url
/// <summary>
/// get image url from sitecore imagefield
/// </summary>
/// <param name="field">imagefield</param>
/// <returns>image url</returns>
public static string GetImageURL(ImageField field)
{
string imageURL = string.Empty;
if (field != null && field.MediaItem != null)
{
Sitecore.Data.Items.MediaItem image = new Sitecore.Data.Items.MediaItem(field.MediaItem);
imageURL = Sitecore.Resources.Media.MediaManager.GetMediaUrl(image);
}
return imageURL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment