我想在我自己的課堂中從Umbraco中獲得圖像。爲什麼我不能在自己的課堂上使用UmbracoHelper
我不明白爲什麼我不能在班上使用@umbraco幫手。我在類中定義的命名空間,如:
using Umbraco.Core.Models;
using Umbraco.Web;
當我寫我只能用UmbracoHelper,:
var umbracoHelper = new UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
這裏是我的類:
using Umbraco.Core.Models;
using Umbraco.Web;
namespace House.Site.Helpers
{
public static class ImageClass
{
public static string GetAbsoluteImageUrl(this IPublishedContent node, string propertyName)
{
var umbracoHelper = new UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
var imgID = node.GetPropertyValue<string>("propertyName");
var imgObject = umbracoHelper.TypedMedia(imgID);
return imgObject.Url;
}
}
}