#5489: Handling potential null value for MediaLibraryPickerField.MediaParts.

This happens when a content type has both a MediaLibraryPickerField and the LayoutPart attached.
The layout editor renders the field, whose shape template accesses the MediaParts property, which is not initialized for new content items.

Fixes #5489
This commit is contained in:
Sipke Schoorstra
2015-07-08 22:45:52 +01:00
parent 89c5b2f7de
commit 9a2eaf7ac9

View File

@@ -7,7 +7,7 @@ using Orchard.MediaLibrary.Models;
namespace Orchard.MediaLibrary.Fields {
public class MediaLibraryPickerField : ContentField {
private static readonly char[] separator = new [] {'{', '}', ','};
private static readonly char[] separator = {'{', '}', ','};
internal Lazy<IEnumerable<MediaPart>> _contentItems;
public int[] Ids {
@@ -17,7 +17,7 @@ namespace Orchard.MediaLibrary.Fields {
public IEnumerable<MediaPart> MediaParts {
get {
return _contentItems.Value;
return _contentItems != null ? _contentItems.Value : Enumerable.Empty<MediaPart>();
}
}