-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters