I am playing around with Umbraco 7 and MVC to get the hang of it. On my textpages I have a media picker. In the "old days" i would have used the umbraco:image control to display the image.
I currently have this working code in my macro:
@{ if (CurrentPage.HasValue("billede")){ var dynamicMediaItem = Umbraco.Media(CurrentPage.billede); <img src="@dynamicMediaItem.GetCropUrl("umbracoFile", "big")" alt="@dynamicMediaItem.Name"/> } }
My question is: Is that the simplest/best way of doing it?
I am asking because I like to keep code and html(templates) as seperated as possible, which means i have to make a macro each time.
I know it's not a lot of code. But I just love the old image control a lot :P
Best practice for displaying media picker image
Hi guys
I am playing around with Umbraco 7 and MVC to get the hang of it. On my textpages I have a media picker. In the "old days" i would have used the umbraco:image control to display the image.
I currently have this working code in my macro:
My question is: Is that the simplest/best way of doing it?
I am asking because I like to keep code and html(templates) as seperated as possible, which means i have to make a macro each time.
I know it's not a lot of code. But I just love the old image control a lot :P
/Michael
Yes, that looks good.
Only way to make it simpler is to use the property value converter package.
Jeavon
Thx for the reply and link Jeavon :)
Will check out the package when I get the chance.
is working on a reply...