There seems to be lots if info on how to do this in xslt, however if I select an image with media picker the the page outputs the id (1193), how can I get the iamge from the id using razor.
Hi. The Library.MediaById is what you need. It returns a dynamically-casted instance of the DynamicMedia class that behaves like DynamicNode. (I.e. you can just call UmbracoFile, UmbracoWidth/Height, etc on it).
Output the image from ultimate picker
Hi,
There seems to be lots if info on how to do this in xslt, however if I select an image with media picker the the page outputs the id (1193), how can I get the iamge from the id using razor.
<umbraco:Item field="ultimate" runat="server" />
So I can get the image output using media picker using the following
<umbraco:Macro runat="server" language="cshtml">
<img src="@Model.MediaById(@Model.mediaPicker).umbracoFile" />
</umbraco:Macro>
<umbraco:Item field="mediaPicker" runat="server" /> // outputs an id
<umbraco:Item field="filePicker" runat="server" /> // ouputs a url
- is there a way to get the height and width with mediaPicker?
- is there a razor function like @Model.MediaByUrl or another way to render the image from the url?
Thanks
Hi. The Library.MediaById is what you need. It returns a dynamically-casted instance of the DynamicMedia class that behaves like DynamicNode. (I.e. you can just call UmbracoFile, UmbracoWidth/Height, etc on it).
is working on a reply...