2013-05-09 88 views

回答

2

您可以使用CmsImport程序包批量導入內容(http://our.umbraco.org/projects/developer-tools/cmsimport)。因此,如果您創建了引用所有站點圖像的文件,則可以在新安裝的內容節點下將它們導入。

這是有點例如剃鬚刀代碼運行圓您的媒體形象,所以你可以一一列舉出來:

@using umbraco.cms.businesslogic.media; 
@using uComponents.Core; 
@using uComponents.Core.uQueryExtensions; 
@using System 
@{ 
    // Set default media root node id 
    int rootNodeId = -1; 

    // Get media node and iterate the children 
    var m = new Media(rootNodeId); 
    var imagesAndFolders = m.GetChildMedia(); 
    var sortedList = m.GetChildMedia().OrderBy(y => y.Text).OrderBy(x => x.ContentType.Alias); 

     @{ 
      foreach (var c in sortedList) 
      { 
      var type = c.ContentType.Alias; 
      switch (type) 
      { 
      case "Folder": 
       //drill into folder 
       break; 
      default: 
       var filePath = c.GetPropertyAsString("umbracoFile"); 
       var thumbPath = c.GetPropertyAsString("umbracoFile").Replace(".","_thumb."); 
       var width = c.GetPropertyAsString("umbracoWidth"); 
       var height = c.GetPropertyAsString("umbracoHeight"); 

        //allowing you to build a table of images 

        <a href="@filePath">@c.Text</a> 
        <a href="@filePath" class="imagePreview">preview &raquo;</a> 
        <a href="@filePath" itemprop="contentURL" download="@c.Text"><img itemprop="thumbnailUrl" src="@thumbPath" alt="@c.Text" /></a> 
       break; 
       } 
      } 
      } 
}