I am trying to get an image from Umbraco in my own class.
I can´t understand why I can not use @umbraco helper in my class. I have its namespace defined in the class, such as:
using Umbraco.Core.Models;
using Umbraco.Web;
I can only use UmbracoHelper, when I write:
var umbracoHelper = new UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
Here is my class:
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;
}
}
}