Files
Umbraco-CMS/src/Umbraco.Web.Common/Extensions/ImageCropperTemplateExtensions.cs

38 lines
1.2 KiB
C#
Raw Normal View History

using System;
using System.Globalization;
2018-01-24 11:44:44 +01:00
using Newtonsoft.Json;
using Umbraco.Composing;
using Umbraco.Core;
2018-01-24 11:44:44 +01:00
using Umbraco.Core.PropertyEditors.ValueConverters;
namespace Umbraco.Extensions
2014-02-17 16:15:39 +01:00
{
/// <summary>
/// Provides extension methods for getting ImageProcessor Url from the core Image Cropper property editor
/// </summary>
2014-02-17 16:15:39 +01:00
public static class ImageCropperTemplateExtensions
{
internal static ImageCropperValue DeserializeImageCropperValue(this string json)
2018-01-24 11:44:44 +01:00
{
var imageCrops = new ImageCropperValue();
if (json.DetectIsJson())
{
try
{
imageCrops = JsonConvert.DeserializeObject<ImageCropperValue>(json, new JsonSerializerSettings
{
Culture = CultureInfo.InvariantCulture,
FloatParseHandling = FloatParseHandling.Decimal
});
}
catch (Exception ex)
{
Current.Logger.LogError(ex, "Could not parse the json string: {Json}", json);
2018-01-24 11:44:44 +01:00
}
}
return imageCrops;
}
2014-02-17 16:15:39 +01:00
}
}