Support plain file path strings as Image Cropper values

This commit is contained in:
Ronald Barendse
2021-09-08 12:07:05 +02:00
parent b145f09368
commit bd8d7b91d6

View File

@@ -167,10 +167,23 @@ namespace Umbraco.Cms.Core.PropertyEditors
{
deserializedValue = null;
if (propVal == null || !(propVal is string str)) return null;
if (!str.DetectIsJson()) return null;
deserializedValue = GetJObject(str, true);
if (!str.DetectIsJson())
{
// Assume the value is a plain string with the file path
deserializedValue = new JObject()
{
{ "src", str }
};
}
else
{
deserializedValue = GetJObject(str, true);
}
if (deserializedValue?["src"] == null) return null;
var src = deserializedValue["src"].Value<string>();
return relative ? _mediaFileManager.FileSystem.GetRelativePath(src) : src;
}