I am trying get the url of an image property.
@Model.Value("foto") only shows Umbraco.Web.PublishedModels.Image
Does anybody know the correct way to do this?
Your type (Umbraco.Web.PublishedModels.Image) should have and Url property that you can use
@{
var foto = Model.Value("foto");
}
<img src="@foto.Url" />
Also, the page/view you are using this code on, could be changed to have the Umbraco.Web.PublishedModels.[PageType] as the model type ([PageType] being the actual type you are working with), then you could just write @Model.Foto.Url
Unable to show Image property in Umbraco 8
I am trying get the url of an image property.
@Model.Value("foto")
only showsUmbraco.Web.PublishedModels.Image
Does anybody know the correct way to do this?Hi,
The value is of the type you've written
Your type (Umbraco.Web.PublishedModels.Image) should have and Url property that you can use
Also, the page/view you are using this code on, could be changed to have the Umbraco.Web.PublishedModels.[PageType] as the model type ([PageType] being the actual type you are working with), then you could just write
@Model.Foto.Url
HTH
Thank you for your reply.
When I use the code from your example I get the following exception message:
Did you find a solution for this - I've just ran in to the same error with a image.url
Thanks,
Url
is a method rather than a property, so you need@image.Url()
.Having this exact same thing. Would appreciate some kind of guidance on this.
I did the following:
This is what I had:
and it didn't work so I changed my code to:
This now works. Hope it helps.
I had the same problem and solved in this way
There is a similar post subject answered the issue.
is working on a reply...