Copied to clipboard

Flag this post as spam?

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


  • Stan 13 posts 53 karma points
    Mar 08, 2014 @ 21:44
    Stan
    0

    Displaying an image (media item) in Partial View Macros

    Hi,

    I am fairly new to Umbraco, and currently need to display some images on a template using a few partial view macros. I have been searching the forumns without much luck. I know this is a bit of hand holding, but can anyone guide me in how to do this specifially in macros? I am getting the image from the image picker, which returns the id. What is the next step?

    Thank you very much in advance!

  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Mar 10, 2014 @ 14:30
    Andy Butland
    100

    Once you have the Id, then a call via the Umbraco helper to @Umbraco.TypedMedia(id) should give you an object with the properties you need to display the image.

  • Charles Afford 1163 posts 1709 karma points
    Mar 10, 2014 @ 20:19
    Charles Afford
    0

    What version of Umbraco?

  • Charles Afford 1163 posts 1709 karma points
    Mar 10, 2014 @ 20:21
    Charles Afford
    0

    You can get the MediaService in context.  Its something like Services.MediaService then you can call GetById(id) which will get you the media object.  You then need to get the "umbracoFile" property of that media object :).  Charlie

  • Stan 13 posts 53 karma points
    Mar 12, 2014 @ 04:49
    Stan
    0

    Hi,

    Currently 6.1.6. thanks you all for your help. the info is very usefull. So far, from my little experience there is little info or documentation on partial view macros and or what additional namespaces i need to include..eg as Charles suggest, i would need the MediaService... that was the missing piece when i tried to use GetById(id). Thanks again guys!!!

  • Charles Afford 1163 posts 1709 karma points
    Mar 13, 2014 @ 10:15
    Charles Afford
    0

    No worries, glad you got it solved.

  • Charles Afford 1163 posts 1709 karma points
    Mar 13, 2014 @ 10:19
    Charles Afford
    0

    If you could put a vote in for MVP that would be great :).  Charlie

    http://our.umbraco.org/people/mvps

Please Sign in or register to post replies

Write your reply to:

Draft