Skip to content

Instantly share code, notes, and snippets.

@adamhopkinson
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamhopkinson/2b2421c9eb5ff5ad5514 to your computer and use it in GitHub Desktop.
Save adamhopkinson/2b2421c9eb5ff5ad5514 to your computer and use it in GitHub Desktop.
Using a Sitecore ImageField
ImageField field = context.Fields["Img"];
if (field != null && field.MediaItem != null)
{
var ImgItem = new Sitecore.Data.Items.MediaItem(field.MediaItem);
var ImgUrl = Sitecore.Resources.Media.MediaManager.GetMediaUrl(ImgItem);
var ImgCaption = field.Alt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment