2016-02-04 16:03:43 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Globalization;
|
2018-01-24 11:44:44 +01:00
|
|
|
|
using Newtonsoft.Json;
|
2020-08-04 14:12:22 +02:00
|
|
|
|
using Umbraco.Composing;
|
2016-02-04 16:03:43 +01:00
|
|
|
|
using Umbraco.Core;
|
2018-01-24 11:44:44 +01:00
|
|
|
|
using Umbraco.Core.PropertyEditors.ValueConverters;
|
2016-02-04 16:03:43 +01:00
|
|
|
|
|
2020-08-04 14:12:22 +02:00
|
|
|
|
namespace Umbraco.Extensions
|
2014-02-17 16:15:39 +01:00
|
|
|
|
{
|
2014-03-24 17:51:52 +00: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
|
|
|
|
|
|
{
|
2018-01-29 19:23:25 +01:00
|
|
|
|
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)
|
|
|
|
|
|
{
|
2018-08-17 15:41:58 +01:00
|
|
|
|
Current.Logger.Error(typeof(ImageCropperTemplateExtensions), 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
|
|
|
|
}
|
|
|
|
|
|
}
|