From fd984bd6135ac50f704034de287c0f2a22a7860d Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 4 Feb 2016 17:14:29 +0100 Subject: [PATCH] Ensures media.Url works properly --- .../Models/PublishedContentBase.cs | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web/Models/PublishedContentBase.cs b/src/Umbraco.Web/Models/PublishedContentBase.cs index adea2564a9..98d7085a78 100644 --- a/src/Umbraco.Web/Models/PublishedContentBase.cs +++ b/src/Umbraco.Web/Models/PublishedContentBase.cs @@ -1,6 +1,9 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; @@ -64,9 +67,22 @@ namespace Umbraco.Web.Models break; case Constants.PropertyEditors.ImageCropperAlias: //get the url from the json format - var val = prop.Value.ToString(); - var crops = val.SerializeToCropDataSet(); - _url = crops != null ? crops.Src : string.Empty; + + var stronglyTyped = prop.Value as ImageCropDataSet; + if (stronglyTyped != null) + { + _url = stronglyTyped.Src; + break; + } + + var json = prop.Value as JObject; + if (json != null) + { + _url = json.ToObject(new JsonSerializer { Culture = CultureInfo.InvariantCulture, FloatParseHandling = FloatParseHandling.Decimal }).Src; + break; + } + + _url = prop.Value.ToString(); break; } break;