mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
#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:
@@ -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>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user