Just started using Razor - I want to pass in a parameter with the name of a property. the property contains a media id. so I need to get the media item from the media id.
I have the following but how can I use a parameter in the way described.
@{ var media = new umbraco.cms.businesslogic.media.Media(Convert.ToInt32(Model.selectImage)); string sImgUrl= media.getProperty("umbracoFile").Value.ToString(); string sImgAlt = media.Text; var sImgAttribs = String.Format(" src='{0}' alt='{1}'", sImgUrl, sImgAlt); <img@Html.Raw(sImgAttribs) /> }
Parameters
Just started using Razor - I want to pass in a parameter with the name of a property. the property contains a media id. so I need to get the media item from the media id.
I have the following but how can I use a parameter in the way described.
Thanks
J
Hi Julian,
Not tested but I think this might work - change .fieldAlias to the alias of your parameter:
Also I think it has better performance if you use Library.MediaById instead, ie:
-Tom
HI Tom
works a treat thanks
J
is working on a reply...