Copied to clipboard

Flag this post as spam?

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


  • WebsterJ 5 posts 25 karma points
    Feb 21, 2012 @ 16:57
    WebsterJ
    0

    Display Single Image Using Razor

    Greetings.

    I just need to display a single image from a media picker field in a document type.  Each document as a single image. I'm trying to find a razor snippet to do this since it appears xslt is going away.

    Document type = RightSidebar
    Property = pageImage

    Using Umbraco 4.7.1

    Did a lot of searching and couldn't quite find what I needed.

    Thanks.

  • Douglas Ludlow 210 posts 366 karma points
    Feb 21, 2012 @ 17:06
    Douglas Ludlow
    0

    Should be as easy as using the following in a macro:

    <img src="@Library.MediaById(Model.pageImage).umbracoFile" alt="" />
  • Douglas Ludlow 210 posts 366 karma points
    Feb 21, 2012 @ 17:11
    Douglas Ludlow
    0

    Whoops, left something out there. I've edited my last post to include the .umbracoFile property.

  • WebsterJ 5 posts 25 karma points
    Feb 21, 2012 @ 17:35
    WebsterJ
    0

    Should I create a scripting file with that in it?  Or some other type of Macro?

    Thanks.

  • Douglas Ludlow 210 posts 366 karma points
    Feb 21, 2012 @ 17:42
    Douglas Ludlow
    0

    Yes, you'll create a razor (cshtml) script and then map a macro to it.

  • WebsterJ 5 posts 25 karma points
    Feb 21, 2012 @ 17:51
    WebsterJ
    0

    Awesome.  worked.  thanks a bunch.

  • Douglas Ludlow 210 posts 366 karma points
    Feb 21, 2012 @ 18:07
    Douglas Ludlow
    0

    No problemo!

  • 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