Skip to content

Commit

Permalink
Merge branch 'release/2.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
dawoe committed Aug 9, 2021
2 parents d8ac92c + 6405ef6 commit 7b8948f
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
image: Visual Studio 2017

# Version format
version: 2.2.0.{build}
version: 2.3.0.{build}

branches:
only:
Expand Down
50 changes: 50 additions & 0 deletions src/Our.Umbraco.Nexu.Parsers/Core/MediaPicker3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Our.Umbraco.Nexu.Common.Interfaces.Models;
using Our.Umbraco.Nexu.Common.Models;
using Umbraco.Core;

namespace Our.Umbraco.Nexu.Parsers.Core
{
public class MediaPicker3 : IPropertyValueParser
{
public bool IsParserFor(string propertyEditorAlias) =>
propertyEditorAlias.Equals("Umbraco.MediaPicker3");

public IEnumerable<IRelatedEntity> GetRelatedEntities(string value)
{
var entities = new List<IRelatedEntity>();

if (!string.IsNullOrWhiteSpace(value))
{
try
{
var jsonValues = JsonConvert.DeserializeObject<JArray>(value);

foreach (var item in jsonValues)
{
if (item["mediaKey"] != null)
{
var mediaKey = item.Value<string>("mediaKey");

var udi = Udi.Create("media", Guid.Parse(mediaKey));

entities.Add(new RelatedMediaEntity
{
RelatedEntityUdi = udi,
});
}
}
}
catch
{
// swallow it
}
}

return entities;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
<Compile Include="Core\BlockListEditorParser.cs" />
<Compile Include="Core\ContentPickerParser.cs" />
<Compile Include="Core\GridParser.cs" />
<Compile Include="Core\MediaPicker3.cs" />
<Compile Include="Core\MediaPickerParser.cs" />
<Compile Include="Core\MultiNodeTreePickerParser.cs" />
<Compile Include="Core\MultiUrlPickerParser.cs" />
Expand Down

0 comments on commit 7b8948f

Please sign in to comment.