diff --git a/src/Umbraco.Web/PropertyEditors/FileUploadPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/FileUploadPropertyEditor.cs index 82477bd5e3..efbeb0644e 100644 --- a/src/Umbraco.Web/PropertyEditors/FileUploadPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/FileUploadPropertyEditor.cs @@ -65,7 +65,7 @@ namespace Umbraco.Web.PropertyEditors static void AutoFillProperties(IContentBase model) { - foreach (var p in model.Properties) + foreach (var p in model.Properties.Where(x => x.PropertyType.PropertyEditorAlias == Constants.PropertyEditors.UploadFieldAlias)) { var uploadFieldConfigNode = UmbracoConfig.For.UmbracoSettings().Content.ImageAutoFillProperties diff --git a/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditor.cs index 53f6c5c362..c39c52c692 100644 --- a/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditor.cs @@ -62,7 +62,7 @@ namespace Umbraco.Web.PropertyEditors static void AutoFillProperties(IContentBase model) { - foreach (var p in model.Properties.Where(x => x.PropertyType.Alias == Constants.PropertyEditors.ImageCropperAlias)) + foreach (var p in model.Properties.Where(x => x.PropertyType.PropertyEditorAlias == Constants.PropertyEditors.ImageCropperAlias)) { var uploadFieldConfigNode = UmbracoConfig.For.UmbracoSettings().Content.ImageAutoFillProperties @@ -70,18 +70,30 @@ namespace Umbraco.Web.PropertyEditors if (uploadFieldConfigNode != null) { - if (p.Value != null){ - var json = p.Value as JObject; - if (json != null && json["src"] != null) - model.PopulateFileMetaDataProperties(uploadFieldConfigNode, json["src"].Value()); - else if (p.Value is string) - { - var config = ApplicationContext.Current.Services.DataTypeService.GetPreValuesByDataTypeId(p.PropertyType.DataTypeDefinitionId).FirstOrDefault(); + if (p.Value != null) + { + JObject json = null; + try + { + json = JObject.Parse((string)p.Value); + } + catch (Newtonsoft.Json.JsonException ex) + { + + } + if (json != null && json["src"] != null) + model.PopulateFileMetaDataProperties(uploadFieldConfigNode, json["src"].Value()); + else if (p.Value is string) + { + var src = p.Value; + var config = ApplicationContext.Current.Services.DataTypeService.GetPreValuesByDataTypeId(p.PropertyType.DataTypeDefinitionId).FirstOrDefault(); var crops = string.IsNullOrEmpty(config) == false ? config : "[]"; - p.Value = "{src: '" + p.Value + "', crops: " + crops + "}"; - model.PopulateFileMetaDataProperties(uploadFieldConfigNode, p.Value == null ? string.Empty : p.Value.ToString()); - } - }else + p.Value = "{src: '" + p.Value + "', crops: " + crops + "}"; + //Only provide the source path, not the whole JSON value + model.PopulateFileMetaDataProperties(uploadFieldConfigNode, src); + } + } + else model.ResetFileMetaDataProperties(uploadFieldConfigNode); } }