I am getting the error: "'System.Web.IHtmlString' does not contain a definition for 'umbracoFile' and no method for 'umbracoFile' was found that supplies a first argument of the type 'System.Web.IHtmlString' (are you missing a 'using'-directive or an assembly reference?).
Can someone tell me what assemply reference I need for this or maybe there is a better way to show the image.
You are welcome. Happy that I could help you - Please remember to mark the question as solve, you do this by click the green tick in the left side, on the post that gives you the solution.
An explanation to why the code you posted did not work...
@Umbraco.Field("MyPicture") does not return the image but the id of the image, which you can then use to fetch the correct image. So if you just write out that piece of code you will get something like 1210, which is the id.
By using the built in Umbraco.Media method the magic happens behind the scenes :)
Thank you for your answer. I knew about the media method returning the ID. But I am confused about depreciated Razor in Umbraco 7 and how to work around it (strongly typed, new documentation or ???)
Get image by MediaPicker not working
Hi. I am trying in Umbraco 7 in Razor to get an image by ImagePicker.
I have read the article of https://our.umbraco.org/DOCUMENTATION/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors/Media-Picker and I am trying with:
@{
var selectedMedia3 = @Umbraco.Field("myPictyre");
<img src="@selectedMedia3.umbracoFile" width="@selectedMedia3.umbracoWidth" height="@selectedMedia3.umbracoHeight" alt="@selectedMedia3.Name"/>
}
I am getting the error: "'System.Web.IHtmlString' does not contain a definition for 'umbracoFile' and no method for 'umbracoFile' was found that supplies a first argument of the type 'System.Web.IHtmlString' (are you missing a 'using'-directive or an assembly reference?).
Can someone tell me what assemply reference I need for this or maybe there is a better way to show the image.
Thank you in advance
//Lars
Hi Lars,
Try this code instead:
You can find the documentation here: https://our.umbraco.org/documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors/Media-Picker use only the dynamic or strongly typed razor examples. Not the dynamic node razor this is deprecated.
Hope this helps,
/Dennis
Hi Dennis
Thank you for
Great, a big thanks from here :-)
//Lars
Hi Lars,
You are welcome. Happy that I could help you - Please remember to mark the question as solve, you do this by click the green tick in the left side, on the post that gives you the solution.
/Dennis
Hi Lars
An explanation to why the code you posted did not work...
@Umbraco.Field("MyPicture") does not return the image but the id of the image, which you can then use to fetch the correct image. So if you just write out that piece of code you will get something like 1210, which is the id.
By using the built in Umbraco.Media method the magic happens behind the scenes :)
Hope this makes sense.
/Jan
Hi Jan
Thank you for your answer. I knew about the media method returning the ID. But I am confused about depreciated Razor in Umbraco 7 and how to work around it (strongly typed, new documentation or ???)
//Lars
Hi Lars,
You can find the documentation for the bult in property editors in Umbraco 7 here: https://our.umbraco.org/documentation/using-umbraco/backoffice-overview/property-editors/Built-in-Property-Editors-v7/
Hope this helps,
/Dennis
Hi Dennis
That helps a lot. Thank you very much for your help :-)
// Lars
is working on a reply...