Search code examples
imageumbraco7

Umbraco - Current node image


I'm trying to get an image from the current node, in Umbraco. I know the way I'm using it is not the best, but I'm trying to understand something. Here is my code :

var image = Node.GetCurrent().GetProperty("image").Value.ToString();
var url = @Umbraco.Media(image).Url;

First, I'm getting the Image value : umb://media/b59274b4328f4f39866144bef8edef58

From this value, I'm trying to get the Url, but my var url is empty.

But, when I try :

@Umbraco.Media(Model.Content.GetPropertyValue("image").ToString()).Url

Everything is working.

I don't understand this.


Solution

  • Ok. I've not found the why.

    I really want someone to answer me why this is not working.

    I've found a workaround :

    @CurrentPage.Image.Url
    

    Thanks !