using System; using System.Globalization; using Newtonsoft.Json; using Umbraco.Composing; using Umbraco.Core; using Umbraco.Core.PropertyEditors.ValueConverters; namespace Umbraco.Extensions { /// /// Provides extension methods for getting ImageProcessor Url from the core Image Cropper property editor /// public static class ImageCropperTemplateExtensions { internal static ImageCropperValue DeserializeImageCropperValue(this string json) { var imageCrops = new ImageCropperValue(); if (json.DetectIsJson()) { try { imageCrops = JsonConvert.DeserializeObject(json, new JsonSerializerSettings { Culture = CultureInfo.InvariantCulture, FloatParseHandling = FloatParseHandling.Decimal }); } catch (Exception ex) { Current.Logger.LogError(typeof(ImageCropperTemplateExtensions), ex, "Could not parse the json string: {Json}", json); } } return imageCrops; } } }