Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Michael 63 posts 211 karma points
    Jun 11, 2014 @ 11:02
    Michael
    0

    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:

    @{      
        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

     

    /Michael

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jun 12, 2014 @ 01:27
    Jeavon Leopold
    0

    Yes, that looks good.

    Only way to make it simpler is to use the property value converter package.

    Jeavon

  • Michael 63 posts 211 karma points
    Jun 12, 2014 @ 10:22
    Michael
    0

    Thx for the reply and link Jeavon :)

    Will check out the package when I get the chance.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies