Orchard 1.7 - contents of Media folders not listed in media library

邮差的信 提交于 2019-12-06 14:02:19

问题


I've got a problem listing the images from the Media directory for my Orchard site. When trying to add an image using the new media picker I see the list of folders, but when I select one the contents are not listed (see image below).

If I 'import' an image it does appear, but I surely don't need to import every file I'm ever going to use each time, do I?

I must be the only person having this problem because I can't find any reference to it any where else on the web, so thanks in advance.

PS. Sorry if my question isn't perfectly formed - it's my first time posting....


回答1:


Enable the Update feature and migrate your media to the media library from there. It's a one-time process after which you can use the media library with all your old media.




回答2:


Ok, I was having this problem as well and just got it fixed. The underlying problem was that there were records in the orchard database for media files that no longer existed. This was because we just changed our project to use Azure storage, and the database was still pointing to images that had been in other areas of our local hard drives. (Orchard was hitting a method to check to see if a blob actually existed while trying to get its public URL, and if it didn't it threw an exception.)

I did two things to fix it. First off, I deleted all of the references to old images from the database. The table [Orchard_MediaLibrary_MediaPartRecord] in the orchard database has all of the filenames. You can check there to see if there are any references to files that you know don't exist.

Secondly, since there are multiple developers working on our CMS, but using a central database, I was worried that it would break again later as we added images to our local azure file systems. I ended up going into the AzureFileSystem.cs file and modifying it to return a blank string instead of throwing an exception if a blob isn't found:

I changed lines 297 and 298 to this:

try
{
    Container.EnsureBlobExists(String.Concat(_root, path));
    return Container.GetBlockBlobReference(String.Concat(_root, path)).Uri.ToString();
}
catch
{
    return "";
}

Now even if it can't find an image it still shows the ones it CAN find.

Hope this helps. You may not be running things through Azure, but you still might be able to delete entries from the database that don't need to be there.



来源:https://stackoverflow.com/questions/18784161/orchard-1-7-contents-of-media-folders-not-listed-in-media-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!