# Conflicts: # src/Umbraco.Abstractions/IImageUrlGenerator.cs # src/Umbraco.Abstractions/ImageUrlGenerationOptions.cs # src/Umbraco.Core/Composing/Current.cs # src/Umbraco.Core/Models/UserExtensions.cs # src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValue.cs # src/Umbraco.Core/Umbraco.Core.csproj # src/Umbraco.Tests/PropertyEditors/ImageCropperTest.cs # src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs # src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs # src/Umbraco.Tests/Runtimes/StandaloneTests.cs # src/Umbraco.Tests/Testing/UmbracoTestBase.cs # src/Umbraco.Web/PropertyEditors/GridPropertyEditor.cs # src/Umbraco.Web/PropertyEditors/RichTextPropertyEditor.cs # src/Umbraco.Web/Runtime/WebInitialComposer.cs # src/Umbraco.Web/Templates/TemplateUtilities.cs
38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using System;
|
|
using System.Globalization;
|
|
using Newtonsoft.Json;
|
|
using Umbraco.Core;
|
|
using Umbraco.Web.Composing;
|
|
using Umbraco.Core.PropertyEditors.ValueConverters;
|
|
|
|
namespace Umbraco.Web
|
|
{
|
|
/// <summary>
|
|
/// Provides extension methods for getting ImageProcessor Url from the core Image Cropper property editor
|
|
/// </summary>
|
|
public static class ImageCropperTemplateExtensions
|
|
{
|
|
internal static ImageCropperValue DeserializeImageCropperValue(this string json)
|
|
{
|
|
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.Error(typeof(ImageCropperTemplateExtensions), ex, "Could not parse the json string: {Json}", json);
|
|
}
|
|
}
|
|
|
|
return imageCrops;
|
|
}
|
|
}
|
|
}
|