Im looking for a way to display an article thumbnail in a news item (blog), but no luck so far.
The article itself display the imagen without a problem using @Umbraco.Field("blogItemImage"), however when I try to call that image from a partial view macro file I get a blank space without the URL.
The other fields (@page.Name and @page.Url) work great. I've struggling a lot with this, any info would be greatly appreciated!
BTW: We have to keep using Umbraco 7, unfortunately the client infraestructure is very old.
Soooo old now with the v7 'dynamic' syntax. Firstly Umbraco.Field will only write out values from the current page, which is why it works on your article page! - but in this macro, you are inside a foreach loop and you want to write out the image from the 'page' variable...
So using 'dynamic' this I think would be
@page.BlogItemImage
But what I can't truly remember is what you'll get when you do that...
Eg it either just works or you'll get the media object and you'll need instead:
@page.BlogItemImage.Url
or whether you'll just get the integer media Id... So if you get a number you need
Dude...I love you. You don't have to apologize, I've been struggling with this old code for soooo long. The answer was @page.BlogItemImage.Url all along.
Displaying an image outside the page (BLOG)
Hey guys!
Im looking for a way to display an article thumbnail in a news item (blog), but no luck so far.
The article itself display the imagen without a problem using @Umbraco.Field("blogItemImage"), however when I try to call that image from a partial view macro file I get a blank space without the URL.
The other fields (@page.Name and @page.Url) work great. I've struggling a lot with this, any info would be greatly appreciated!
BTW: We have to keep using Umbraco 7, unfortunately the client infraestructure is very old.
Here it is the partial view:
Hi Daniel
Soooo old now with the v7 'dynamic' syntax. Firstly Umbraco.Field will only write out values from the current page, which is why it works on your article page! - but in this macro, you are inside a foreach loop and you want to write out the image from the 'page' variable...
So using 'dynamic' this I think would be
@page.BlogItemImage
But what I can't truly remember is what you'll get when you do that...
Eg it either just works or you'll get the media object and you'll need instead:
@page.BlogItemImage.Url
or whether you'll just get the integer media Id... So if you get a number you need
@Umbraco.Media(page.BlogItemImage).Url
Sorry its been a while!
Regards
Marc
Dude...I love you. You don't have to apologize, I've been struggling with this old code for soooo long. The answer was @page.BlogItemImage.Url all along.
Thank you so much!
is working on a reply...