【发布时间】:2017-01-20 05:40:14
【问题描述】:
我正在尝试从我自己班级的 Umbraco 获取图像。
我不明白为什么我不能在课堂上使用@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;
}
}
}
【问题讨论】:
标签: c# asp.net-mvc umbraco umbraco7