/// <summary>
        /// Map image crops model
        /// </summary>
        /// <param name="media">Media node</param>
        /// <param name="image">Image model</param>
        private static void MapImageCrops(IPublishedContent media, ImageViewModel image)
        {
            if (media == null)
            {
                return;
            }

            var imageString = media.GetPropertyValue<string>(PropertyAliases.UmbracoFile);
            var imageCrops = JsonHelper.Deserialize<ImageCropperModel>(imageString);
            image.Crops = imageCrops.Crops.ToDictionary(x => x.Alias, x => media.GetCropUrl(x.Alias));
        }
        /// <summary>
        /// Helper method for displaying an image
        /// </summary>
        /// <param name="helper">Html helper</param>
        /// <param name="image">Image view model</param>
        /// <param name="cropAlias">Crop alias</param>
        /// <returns>Picture tag as Html string</returns>
        public static IHtmlString DisplayImage(this HtmlHelper helper, ImageViewModel image, string cropAlias)
        {
            if (!ValidateArgs(image, cropAlias))
            {
                return null;
            }

            var imgTag = new TagBuilder("img");
            imgTag.Attributes.Add("alt", image.AltText);
            imgTag.Attributes.Add("class", "img-responsive");
            imgTag.Attributes.Add("src", image.Crops[cropAlias]);
            var pictureTag = new TagBuilder("picture")
            {
                InnerHtml = imgTag.ToString(TagRenderMode.SelfClosing)
            };

            return new HtmlString(pictureTag.ToString());
        }
 private static bool ValidateArgs(ImageViewModel image, string cropAlias)
 {
     return image != null && image.Crops != null && cropAlias != null && image.Crops.ContainsKey(cropAlias);
 }
 /// <summary>
 /// Helper method for applying background image styling
 /// </summary>
 /// <param name="helper">Html helper</param>
 /// <param name="image">Image model</param>
 /// <param name="cropAlias">Crop alias</param>
 /// <returns>Style attribute</returns>
 public static IHtmlString DisplayBackgroundImage(this HtmlHelper helper, ImageViewModel image, string cropAlias)
 {
     return ValidateArgs(image, cropAlias) ? helper.DisplayBackgroundImage(image.Crops[cropAlias]) : null;
 }