I'm using Umbraco Examine and want to display an image
@if(node.Fields.Keys.Contains("huvudBild")) { var image = node.Fields["huvudBild"];
@image }
Right now I'm using this code which gives me the path to the image but with some numbers at the end causing the url to be wrong. Should mention that I'm also using Damp. Any ideas on how to solve this problem?
By the way, you can solve it in a much more pretty way, take your xml and convert it to dynamicxml and then just query it like you would query the model:
@{ var field = Library.ToDynamicXml(node.Fields["huvudBild"]); } @field.image
Showing image in search results
Hi!
I'm using Umbraco Examine and want to display an image
@if(node.Fields.Keys.Contains("huvudBild"))
{
var image = node.Fields["huvudBild"];
@image
}
Right now I'm using this code which gives me the path to the image but with some numbers at the end causing the url to be wrong. Should mention that I'm also using Damp. Any ideas on how to solve this problem?
Thanks / Niklas
It's because node.Fields is probably XML and the numbers are values in the other elements of your xml.
Can you tell me what "node" is? Is that something from Examine or is it a proper DynamicNode from Razor?
Hi Sebastiaan
Yes you're right. Had to do a regex and now it works fine :)
A regex! Ouch.. now you have two problems... ;-)
By the way, you can solve it in a much more pretty way, take your xml and convert it to dynamicxml and then just query it like you would query the model:
is working on a reply...