AB3226 - Added MediaPicker references

This commit is contained in:
Bjarke Berg
2019-10-28 12:56:54 +01:00
parent 5699dc32b7
commit c52adf76f7

View File

@@ -1,5 +1,7 @@
using Umbraco.Core;
using System.Collections.Generic;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Models.Editors;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Web.PropertyEditors
@@ -17,14 +19,32 @@ namespace Umbraco.Web.PropertyEditors
Icon = Constants.Icons.MediaImage)]
public class MediaPickerPropertyEditor : DataEditor
{
/// <summary>
/// Initializes a new instance of the <see cref="MediaPickerPropertyEditor"/> class.
/// </summary>
public MediaPickerPropertyEditor(ILogger logger)
: base(logger)
{ }
{
}
/// <inheritdoc />
protected override IConfigurationEditor CreateConfigurationEditor() => new MediaPickerConfigurationEditor();
protected override IDataValueEditor CreateValueEditor() => new MediaPickerPropertyValueEditor(Attribute);
}
public class MediaPickerPropertyValueEditor : DataValueEditor, IDataValueReference
{
public MediaPickerPropertyValueEditor(DataEditorAttribute attribute) : base(attribute)
{
}
public IEnumerable<UmbracoEntityReference> GetReferences(object value)
{
var asString = value == null ? string.Empty : value is string str ? str : value.ToString();
yield return new UmbracoEntityReference(Udi.Parse(asString));
}
}
}