mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-07-31 21:32:56 +08:00
Fixing media picker migration issue
This commit is contained in:
parent
673ef2c0a5
commit
5c1b979192
@ -185,13 +185,16 @@ namespace Upgrade.Controllers {
|
||||
string url = Convert.ToString(contentField.Url);
|
||||
var filename = Path.GetFileName(url);
|
||||
string folder = Path.GetDirectoryName(url);
|
||||
var mediaItems = _orchardServices.ContentManager.Query().ForPart<MediaPart>().Where<MediaPartRecord>(x => filename == x.FileName).List().ToList();
|
||||
var mediaItems = _orchardServices.ContentManager.Query<MediaPart, MediaPartRecord>().Where(x => filename == x.FileName).List().ToList();
|
||||
MediaPart media = null;
|
||||
|
||||
// in case multiple media have the same filename find based on the folder
|
||||
if (mediaItems.Count() > 1) {
|
||||
media = mediaItems.FirstOrDefault(x => folder.EndsWith(x.FolderPath));
|
||||
}
|
||||
else {
|
||||
media = mediaItems.FirstOrDefault();
|
||||
}
|
||||
|
||||
if (media != null) {
|
||||
contentField.Url = "{" + media.Id + "}";
|
||||
|
Loading…
Reference in New Issue
Block a user