public static string ResizeBackground(this HtmlHelper helper, ContentReference image,
                                              BackgroundPictureProfile profile)
        {
            if (image == null)
            {
                return("error-no-image");
            }

            var className = "_" + Guid.NewGuid().ToString("N");
            var styles    = GenerateMediaQueryStyles(helper, profile, image, className);

            helper.RenderXhtmlString(new XhtmlString(styles));
            return(className);
        }
        private static string GenerateMediaQueryStyles(HtmlHelper helper, BackgroundPictureProfile profile,
                                                       ContentReference image, string className)
        {
            var stringBuilder = new StringBuilder();

            stringBuilder.Append("<style>");

            foreach (var allowedSize in profile.AllowedSizes.Reverse())
            {
                var mediaQuery = helper.Encode(allowedSize.MediaCondition);

                RenderNonRetinaCss(helper, image, mediaQuery, stringBuilder, className, allowedSize, profile.Format);
                RenderRetinaCss(helper, image, mediaQuery, stringBuilder, className, allowedSize, profile.Format);
            }

            stringBuilder.Append("</style>");
            return(stringBuilder.ToString());
        }